Web x.0
Web x.0
Module 1- Introduc
The "Semantic Web Stack" refers to a conceptual framework for understanding and implementing technologies
that enable the Semantic Web. The Semantic Web is an extension of the World Wide Web that aims to make web
content more understandable by computers, allowing them to process and interpret information in a meaningful
way.
The Semantic Web Stack typically consists of several layers, each building upon the others to achieve its goals:
At the base of the stack is the concept of URIs, which uniquely identify resources on the web. URIs serve as the
foundation for linking and referencing data across the web.
XML provides a standardized format for structuring and encoding data on the web. It allows information to be
organized hierarchically and tagged with metadata, making it easier for computers to understand and process.
RDF is a data model used to describe resources and their relationships on the web. It represents information in
the form of triples (subject-predicate-object), enabling the creation of rich, interconnected datasets.
OWL is a language for defining ontologies, which specify the concepts and relationships within a particular
domain. Ontologies provide a formal framework for representing knowledge and enabling automated reasoning
about data.
SPARQL is a query language and protocol for querying RDF data. It allows users to retrieve and manipulate
information stored in RDF datasets, enabling powerful search and analysis capabilities across the Semantic Web.
By leveraging technologies across these layers, the Semantic Web aims to enhance the interoperability,
discoverability, and interpretability of web content, ultimately enabling more intelligent and efficient information
processing on the internet.
Often, clickstream analysis factors in various analytics, such as user or session analytics, to compare
how different groups of users interact with the same website. User analytics, like the user’s gender
(if that data is available), allow webmasters to see how their content appeals to different audiences.
Session analytics, like how the user reached the website, allow webmasters to compare their traffic
sources.
In add
clickstream analysis to gain insights into user behavior on third-party sites and pl
example, businesses can analyze user behavior on social media pl
marketplaces to id
Webmasters can use clickstream analysis to compare traffic channels if they know how their users
first reached the website. With most website analytics tools, webmasters will have this information;
for example, whether a given user reached the website through a search engine, social media, or by
typing the website’s URL into their browser.
From the clickstream data itself, a webmaster may be able to identify that users from certain
channels view more or less pages, on average. For example, they may notice that users from search
engines view twice as many pages as users from social media. As a result of this, the webmaster may
choose to focus more resources on the former channel.
Webmasters that use paid advertising to drive visitors to their website can go one step further and
compare individual advertising strategies. Just like before, a webmaster can compare how users
from various advertising media interact with their website, to see where advertising is most
effective.
Sometimes. clickstream data may also include information about what actions users take, and not
just what pages they visit. If this is the case, websites like online shops may choose to compare
various advertising strategies against the number of sales made through them, and not the number
of pages visited.
Clickstream analysis can still be incredibly powerful, even without session analytics. By looking at the
path users take through a website, webmasters are able to see where users “drol ojj”. With this
information, they can choose to improve the pieces of content which caused users to leave the
website.
Similarly, clickstream data alone can be used to interlink between existing content. Interlinking is
simply the process of linking between pages on the same website. With clickstream data,
webmasters can identify pages with few links (as more users might be leaving the website on those
pages) and add more of them.
RDF enables the creation of semantic graphs, where nodes represent resources and edges
represent relationships, facilitating the integration and exchange of data across diverse
applications and domains.
In this query:
The PREFIX declaration establishes a namespace prefix ( dc ) for the Dublin Core metadata terms.
The SELECT statement specifies that we want to retrieve the ?title of the books.
The WHERE clause defines the pattern to match in the dataset. It specifies that for each ?book, we
want to retrieve its dc:title.
When executed against a dataset containing RDF data about books, this query would return a list
of all book titles available in the dataset.
Module:02 Typescript
[Link] how the typescript program can be executed on windows/Linux OS?
TypeScript is an open-source programming language. It is developed and maintained by Microsoft.
TypeScript follows JavaScript syntactically but adds more features to it. It is a superset of
JavaScript. In order to execute or run any typescript file, first you need to install node and using it
install typescript globally in your local system.
Syntax:
To check node is installed, run command if not you have to installed it first:
node -v
Now to install typescript, use:
npm install -g typescript
After installing typescript, create a .ts file, for example, [Link] as given below:
Example:
Output:
Greetings from GeeksforGeeks
Procedure 1: This typescript file [Link] will create a javascript file at runtime with the same
name. To run any typescript file there are a few ways: Syntax:
Step 1: First, run the typescript file with the following command. This will create a
javascript file from typescript automatically with the same name.
tsc [Link]
Step 2:Now run the javascript file, the [Link] file will get executed:
node [Link]
Procedure 2: You can merge both the commands by using a pole | and && like below : Syntax:
In Windows:
tsc [Link] | node [Link]
In Linux or MacOS:
tsc [Link] && node [Link]
Procedure 3: You can also install ts-node along with typescript using the following
command: Syntax:
To install:
npm install -g ts-node
To run:
ts-node [Link]
Output: Using any of the three ways, the output will remain the same.
Greetings from GeeksforGeeks
The TypeScript language supports different types of values. It provides data types for the JavaScript
to transform it into a strongly typed programing language. JavaScript doesn't support data types, but
with the help of TypeScript, we can use the data types feature in JavaScript. TypeScript plays an
important role when the object-oriented programmer wants to use the type feature in any scripting
language or object-oriented programming language. The Type System checks the validity of the
given values before the program uses them. It ensures that the code behaves as expected.
TypeScript provides data types as an optional Type System. We can classify the TypeScript data type
as following.
1. St
In the context of type systems, static types mean "at compile time" or "without running a program."
In a statically typed language, variables, parameters, and objects have types that the compiler knows
at compile time. The compiler used this information to perform the type checking.
ADVERTISEMENT
The TypeScript has five built-in data types, which are given below.
Number
Like JavaScript, all the numbers in TypeScript are stored as floating-point values. These numeric
values are treated like a number data type. The numeric data type can be used to represents both
integers and fractions. TypeScript also supports Binary(Base 2), Octal(Base 8), Decimal(Base 10), and
Hexadecimal(Base 16) literals.
Syntax:
Examples:-
String
We will use the string data type to represents the text in TypeScript. String type work with textual
data. We include string literals in our scripts by enclosing them in single or double quotation marks.
It also represents a sequence of Unicode characters. It embedded the expressions in the form of $
{expr}.
Syntax
ADVERTISEMENT
ADVERTISEMENT
Examples
Boolean
The string and numeric data types can have an unlimited number of different values, whereas the
Boolean data type can have only two values. They are "true" and "false." A Boolean value is a truth
value which specifies whether the condition is true or not.
Syntax
Examples
Void
A void is a return type of the functions which do not return any type of value. It is used where no
data type is available. A variable of type void is not useful because we can only assign undefined or
null to them. An undefined data type denotes uninitialized variable, whereas null represents a
variable whose value is undefined.
Syntax
Examples
Null
Null represents a variable whose value is undefined. Much like the void, it is not extremely useful on
its own. The Null accepts the only one value, which is null. The Null keyword is used to define the
Null type in TypeScript, but it is not useful because we can only assign a null value to it.
Examples
nndefined
The Undefined primitive type denotes all uninitialized variables in TypeScript and JavaScript. It has
only one value, which is undefined. The undefined keyword defines the undefined type in
TypeScript, but it is not useful because we can only assign an undefined value to it.
ADVERTISEMENT
Example
Any Type
It is the "super type" of all data type in TypeScript. It is used to represents any JavaScript value. It
allows us to opt-in and opt-out of type-checking during compilation. If a variable cannot be
represented in any of the basic data types, then it can be declared using "Any" data type. Any type is
useful when we do not know about the type of value (which might come from an API or 3rd party
library), and we want to skip the type-checking on compile time.
ADVERTISEMENT
ADVERTISEMENT
Syntax
Examples
User-Defined DataType
Array
An array is a collection of elements of the same data type. Like JavaScript, TypeScript also allows us
to work with arrays of values. An array can be written in two ways:
1. Use the type of the elements followed by [] to denote an array of that element type:
Touple
The Tuple is a data type which includes two sets of values of different data types. It allows us to
express an array where the type of a fixed number of elements is known, but they are not the same.
For example, if we want to represent a value as a pair of a number and a string, then it can be
written as:
1. // Declare a tuple
2. let a: [string, number];
3.
4. // In it
5. a = ["hi", 8, "how", 5]; // OK
Interface
An Interface is a structure which acts as a contract in our application. It defines the syntax for classes
to follow, means a class which implements an interface is bound to implement all its members. It
cannot be instantiated but can be referenced by the class which implements it. The TypeScript
compiler uses interface for type-checking that is also known as "duck typing" or "structural
subtyping."
Example
1. interface Calc {
2. subtract (first: number, second: number): any;
3. }
4.
5. let Calculator: Calc = {
6. subtract(first: number, second: number) {
7. return first - second;
8. }
9. }
Class
Classes are used to create reusable components and acts as a template for creating objects. It is a
logical entity which store variables and functions to perform operations. TypeScript gets support for
classes from ES6. It is different from the interface which has an implementation inside it, whereas an
interface does not have any implementation inside it.
Example
1. class Student
2. {
3. RollNo: number;
4. Name: string;
5. constructor(_RollNo: number, Name: string)
6. {
7. [Link] = _rollNo;
8. [Link] = _name;
9. }
10. showDetails()
11. {
12. [Link]([Link] + " : " + [Link]);
13. }
14. }
Enums
Enums define a set of named constant. TypeScript provides both string-based and numeric-based
enums. By default, enums begin numbering their elements starting from 0, but we can also change
this by manually setting the value to one of its elements. TypeScript gets support for enums from
ES6.
Example
1. enum Color {
2. Red, Green, Blue
3. };
4. let c: Color;
5. ColorColor = [Link];
Functions
A function is the logical blocks of code to organize the program. Like JavaScript, TypeScript can also
be used to create functions either as a named function or as an anonymous function. Functions
ensure that our program is readable, maintainable, and reusable. A function declaration has a
function's name, return type, and parameters.
Example
Generic is used to create a component which can work with a variety of data type rather than a
single one. It allows a way to create reusable components. It ensures that the program is flexible as
well as scalable in the long term. TypeScript uses generics with the type variable <T> that denotes
types. The type of generic functions is just like non-generic functions, with the type parameters
listed first, similarly to function declarations.
Example
3. Decorators
A decorator is a special of data type which can be attached to a class declaration, method, property,
accessor, and parameter. It provides a way to add both annotations and a meta-programing syntax
for classes and functions. It is used with "@" symbol.
A decorator is an experimental feature which may change in future releases. To enable support for
the decorator, we must enable the experimentalDecorators compiler o command
line or in our tsconfi[Link].
let and const are two relatively new concepts for variable declarations in JavaScript. As we
mentioned earlier, let is similar to var in some respects, but allows users to avoid some of the
common “kotchas” that users run into in JavaScript.
With TypeScript being an extension of JavaScript, the language naturally supports let and const. Here
we’ll elaborate more on these new declarations and why theo’re preferable to var.
If oou’ve used JavaScript offhandedly, the next section might be a good way to refresh your memory.
If oou’re intimately familiar with all the quirks of var declarations in JavaScript, you might find it
easier to skip ahead.
var declar
Declaring a variable in JavaScript has always traditionally been done with the var keyword.
var a = 10;
As you mikht’ve figured out, we just declared a variable named a with the value 10.
function f() {
var message = "Hello, world!";
return message;
}
An Operator is a symbol which operates on a value or data. It represents a specific action on working
with data. The data on which operators operates is called operand. It can be used with one or more
than one values to produce a single value. All of the standard JavaScript operators are available with
the TypeScript program.
Example
1. 10 + 10 = 20;
In the above example, the values '10' and '20' are known as an operand, whereas '+' and '=' are known
as operators.
Operators in TypeScript
ADVERTISEMENT
ADVERTISEMENT
o Arithm
o Comparison (R
o Logical operators
o Bitwise operators
o Assignment operators
o Ternary/cond
o Concat
o Type Operator
Arithm
Arithmetic operators take numeric values as their operands, performs an action, and then returns a
single numeric value. The most common arithmetic operators are addition(+), subtraction(-),
multiplication(*), and division(/).
ADVERTISEMENT
ADVERTISEMENT
Comparison (R
The comparison operators are used to compares the two operands. These operators return a Boolean
value true or false. The important comparison operators are given below.
Logical Operators
Logical operators are used for combining two or more condition into a single expression and return
the Boolean result true or false. The Logical operators are given below.
Bitwise Operators
The bitwise operators perform the bitwise operations on operands. The bitwise operators are as
follows.
Assignment Operators
Assignment operators are used to assign a value to the variable. The left side of the assignment
operator is called a variable, and the right side of the assignment operator is called a value. The data-
type of the variable and value must be the same otherwise the compiler will throw an error. The
assignment operators are as follows.
Operator Operator_Name Descrip Example
operand.
operand.
operand.
operand.
operand.
Ternary/Cond
The conditional operator takes three operands and returns a Boolean value based on the condition,
whether it is true or false. Its working is similar to an if-else statement. The conditional operator has
right-to-left associativity. The syntax of a conditional operator is given below.
Example
Output:
True
Concat
The concatenation (+) operator is an operator which is used to append the two string. In concatenation
operation, we cannot add a space between the strings. We can concatenate multiple strings in a single
statement. The following example helps us to understand the concatenation operator in TypeScript.
Example
1. let message = "Welcome to " + "JavaTpoint";
2. [Link]("Result of String Operator: " +message);
Output:
Type Operators
There are a collection of operators available which can assist you when working with objects in
TypeScript. Operators such as typeof, instanceof, in, and delete are the examples of Type operator.
The detail explanation of these operators is given below.
Javascript
let Employee_details = {
Empname: "John",
EmpSection: "field"
}
[Link]("Employee Name is:" +
Employee_details.Empname +
" Employee's section is:"
+ Employee_details.EmpSection
);
Output:
Module 03:Angularjs
Q2. Explain two way data binding in angularjs?
In AngularJS, Data Binding refers to the synchronization between the model and view. In Two-way
data binding, the flow of data is bidirectional i.e. when the data in the model changes, the changes
are reflected in the view and when the data in the view changes it is reflected in the model. Two-
way data binding is achieved by using the ng-model directive. The ng-model directive transfers data
from the view to the model and from the model to the view.
Approach: The following approach will be implemented to achieve the Two-way Binding:
Create a module
var app=[Link]('myApp',[])
Add a controller to the module. Here you can write the logic for updating the model as
the view changes.
[Link]('myCtrl',function($scope){})
Specify the ng-model directive in the element
<input ng-model="name"/>
[Link] a code to use ng-repeat directive for iterations to display students data.(Assume suitable
data)
<body ng-app="myApp" ng-controller="myCtrl">
<script>
var app = [Link]("myApp", []);
[Link]("myCtrl", func ($scope) {
$[Link] = [
"Alfreds F ,
"Berglunds snabbköl",
"Centro comercial
Moctezuma",
"Ernst Handel",
]
});
</script>
</body>
[Link] a code using angularjs for calculator which should accept two input and display its output
on the web form itself.(Have atleast two buttons) examples/angular/[Link]
examples/angular/[Link]
1. [Link]('CalculatorApp', [])
2. .controller('CalculatorController', function($scope) {
3. $[Link] = function() {
4. if ($[Link] == '+') {
5. return $scope.a + $scope.b;
6. }
7. if ($[Link] == '-') {
8. return $scope.a - $scope.b;
9. }
10. if ($[Link] == '*') {
11. return $scope.a * $scope.b;
12. }
13. if ($[Link] == '/') {
14. return $scope.a /
$scope.b;
15. } 16. }; 17. });