Introduction To The Semantic Web (Tutorial) Johnson & Johnson Philadelphia, USA October 30, 2009 Ivan Herman, W3C
Introduction To The Semantic Web (Tutorial) Johnson & Johnson Philadelphia, USA October 30, 2009 Ivan Herman, W3C
airline preferences
dietary requirements
calendaring
etc
What is needed?
Michael Grove, Clark & Parsia, LLC, and Andrew Schain, NASA, (SWEO Case Study)
10
11
12
It is that simple
13
In what follows
14
queries that could not have been done on the individual data
sets
Author Title
id_xyz The Glass Palace
Publisher
id_qpr
ID
id_xyz
Name
Ghosh, Amitav
Home Page
http://www.amitavghosh.com
ID
id_qpr
Publ. Name
Harper Collins
City
London
Year
2000
15
16
17
11
12
13
ID
ISBN0 2020386682
Traducteur
Titre
Original
Le Palais A13
ISBN-0-00-651409-X
des
miroirs
ID
ISBN-0-00-651409-X
Auteur
A12
2
3
Nom
Ghosh, Amitav
Besse, Christianne
18
19
20
21
22
23
24
25
26
27
28
29
30
Is that surprising?
31
32
33
34
35
RDF triples
36
(<http://isbn6682>,
(<http://isbn6682>, <http:///original>,
<http:///original>, <http://isbn409X>)
<http://isbn409X>)
37
http://www.example.org/file.xml#element(home)
http://www.example.org/file.html#home
http://www.example.org/file2.xml#xpath1(//q[@a=b])
http://www.ivan-herman.net/me is me
not my home page, not my publication list, but me
38
39
<rdf:Description
<rdf:Description rdf:about="http:///isbn/2020386682">
rdf:about="http:///isbn/2020386682">
<f:titre
xml:lang="fr">Le
<f:titre xml:lang="fr">Le palais
palais des
des mirroirs</f:titre>
mirroirs</f:titre>
<f:original
rdf:resource="http:///isbn/000651409X"/>
<f:original rdf:resource="http:///isbn/000651409X"/>
</rdf:Description>
</rdf:Description>
<http:///isbn/2020386682>
<http:///isbn/2020386682>
f:titre
f:titre "Le
"Le palais
palais des
des mirroirs"@fr
mirroirs"@fr ;;
f:original
f:original <http:///isbn/000651409X>
<http:///isbn/000651409X> ..
40
Internal nodes
41
42
43
</rdf:Description>
</rdf:Description>
</a:publisher>
</a:publisher>
</rdf:Description>
</rdf:Description>
Same in Turtle
<http:///isbn/000651409X>
<http:///isbn/000651409X> a:publisher
a:publisher [[
a:p_name
a:p_name "HarpersCollins";
"HarpersCollins";
].
].
44
45
triples
(property,object) pairs for a specific subject
(subject,property) pairs for specific object
etc.
46
Jena example
//
// create
create aa model
model
Model
model=new
Model model=new ModelMem();
ModelMem();
Resource
subject=model.createResource("URI_of_Subject")
Resource subject=model.createResource("URI_of_Subject")
//
// 'in'
'in' refers
refers to
to the
the input
input file
file
model.read(new
InputStreamReader(in));
model.read(new InputStreamReader(in));
StmtIterator
StmtIterator iter=model.listStatements(subject,null,null);
iter=model.listStatements(subject,null,null);
while(iter.hasNext())
while(iter.hasNext()) {{
st
st == iter.next();
iter.next();
pp == st.getProperty();
st.getProperty();
oo == st.getObject();
st.getObject();
do_something(p,o);
do_something(p,o);
}}
47
Merge in practice
48
49
50
51
Classes, resources,
fiction, novel,
52
53
54
55
56
Inferred properties
(<http:///isbn/000651409X>
(<http:///isbn/000651409X> rdf:type
rdf:type #Fiction)
#Fiction)
57
if such and such triples are in the graph, add this and this
do that recursively until the graph does not change
58
Properties
59
all resources bound by the sub are also bound by the other
In RDF/XML:
<rdf:Property
<rdf:Property rdf:ID="title">
rdf:ID="title">
<rdfs:domain
<rdfs:domain rdf:resource="#Fiction"/>
rdf:resource="#Fiction"/>
<rdfs:range
rdf:resource="http://...#Literal"/>
<rdfs:range rdf:resource="http://...#Literal"/>
</rdf:Property>
</rdf:Property>
In Turtle:
:title
:title
rdf:type
rdf:Property;
rdf:type
rdf:Property;
rdfs:domain
rdfs:domain :Fiction;
:Fiction;
rdfs:range
rdfs:Literal.
rdfs:range rdfs:Literal.
60
61
Literals
62
<http:///isbn/000651409X>
<http:///isbn/000651409X>
:page_number
:page_number "543"^^xsd:integer
"543"^^xsd:integer ;;
:publ_date
:publ_date "2000"^^xsd:gYear
"2000"^^xsd:gYear ;;
:price
"6.99"^^xsd:float
:price
"6.99"^^xsd:float ..
63
64
Keep data in
databases or XML,
just export key fact
as RDF
Use a faceted
browser to visualize
and interact with the
result
Courtesy of Nigel Wilkinson, Lee Harland, Pfizer Ltd, Melliyal Annamalai, Oracle (SWEO Case Study)
65
66
Simple approach
67
extract the structure from the page and convert the content
into RDF
add RDF statements directly into XHTML via RDFa
68
Extract RDF
69
dc:subject
dc:subject "Some
"Some subject";
subject";
dc:date
"2006-01-02"
dc:date "2006-01-02" ..
70
Otherwise it is identical
71
72
73
Linking Data
74
75
dbpedia
dbpedia
dbterm
dbterm
76
<http://dbpedia.org/resource/>.
<http://dbpedia.org/resource/>.
<http://dbpedia.org/property/>.
<http://dbpedia.org/property/>.
dbpedia:Amsterdam
dbpedia:Amsterdam
dbterm:officialName
dbterm:officialName Amsterdam
Amsterdam ;;
dbterm:longd
dbterm:longd 4
4 ;;
dbterm:longm
dbterm:longm 53
53 ;;
dbterm:longs
dbterm:longs 32
32 ;;
...
...
dbterm:leaderTitle
dbterm:leaderTitle Mayor
Mayor ;;
dbterm:leaderName
dbterm:leaderName dbpedia:Job_Cohen
dbpedia:Job_Cohen ;;
...
...
dbterm:areaTotalKm
dbterm:areaTotalKm 219
219 ;;
...
...
dbpedia:ABN_AMRO
dbpedia:ABN_AMRO
dbterm:location
dbterm:location dbpedia:Amsterdam
dbpedia:Amsterdam ;;
...
...
<http://sws.geonames.org/2759793>
<http://sws.geonames.org/2759793>
owl:sameAs
owl:sameAs <http://dbpedia.org/resource/Amsterdam>
<http://dbpedia.org/resource/Amsterdam>
wgs84_pos:lat
wgs84_pos:lat 52.3666667
52.3666667 ;;
wgs84_pos:long
wgs84_pos:long 4.8833333
4.8833333 ;;
geo:inCountry
geo:inCountry <http://www.geonames.org/countries/#NL>
<http://www.geonames.org/countries/#NL> ;;
...
...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
SELECT
SELECT ?isbn
?isbn ?price
?price ?currency
?currency ## note:
note: not
not ?x!
?x!
WHERE
{?isbn
a:price
?x.
?x
rdf:value
?price.
WHERE {?isbn a:price ?x. ?x rdf:value ?price. ?x
?x p:currency
p:currency ?currency.}
?currency.}
94
SELECT
SELECT ?isbn
?isbn ?price
?price ?currency
?currency ## note:
note: not
not ?x!
?x!
WHERE
{?isbn
a:price
?x.
?x
rdf:value
?price.
WHERE {?isbn a:price ?x. ?x rdf:value ?price. ?x
?x p:currency
p:currency ?currency.}
?currency.}
Returns:
[[<..49X>,33,], [<..49X>,50,], [<..6682>,60,],
[<..6682>,78,$]]
Pattern constraints
95
SELECT
SELECT ?isbn
?isbn ?price
?price ?currency
?currency ## note:
note: not
not ?x!
?x!
WHERE
{
?isbn
a:price
?x.
?x
rdf:value
?price.
WHERE { ?isbn a:price ?x. ?x rdf:value ?price. ?x
?x p:currency
p:currency ?currency.
?currency.
FILTER(?currency
==
}
FILTER(?currency == }
96
97
98
99
100
Ontologies
(OWL)
Ontologies
characterization of properties
identification of objects with different URI-s
disjointness or equivalence of classes
construct classes, not only name them
can a program reason about some terms? E.g.:
etc.
101
Ontologies (cont.)
102
It is a separate recommendation
103
OWL is complex
104
Term equivalences
For classes:
For properties:
owl:equivalentProperty
owl:propertyDisjointWith
For individuals:
105
106
Connecting to French
107
Property characterization
108
:email
:email rdf:type
rdf:type owl:InverseFunctionalProperty.
owl:InverseFunctionalProperty.
<A>
:email
"
mailto:[email protected]
<A> :email "mailto:[email protected]""..
<B>
<B> :email
:email ""mailto:[email protected]
mailto:[email protected]""..
109
ex:born_in_country
ex:born_in_country owl:propertyChainAxiom
owl:propertyChainAxiom
(ex:born_in_city
(ex:born_in_city ex:city_in_country).
ex:city_in_country).
110
Keys (OWL 2)
111
Keys (OWL 2)
112
:Person
:Person rdf:type
rdf:type owl:Class;
owl:Class;
owl:hasKey
(:email
owl:hasKey (:email :homepage)
:homepage) ..
113
What it means is
If:
<A>
<A> rdf:type
rdf:type :Person
:Person ;;
:email
""mailto:[email protected]
:email
mailto:[email protected]"";;
:homepage
:homepage ""http://www.ex.org
http://www.ex.org""..
<B>
<B> rdf:type
rdf:type :Person
:Person ;;
:email
""mailto:[email protected]
:email
mailto:[email protected]"";;
:homepage
:homepage ""http://www.ex.org
http://www.ex.org""..
114
Classes in OWL
115
ex:Person
ex:Person rdf:type
rdf:type owl:Class.
owl:Class.
<uri-for-Amitav-Ghosh>
<uri-for-Amitav-Ghosh>
rdf:type
rdf:type owl:Thing;
owl:Thing;
rdf:type
owl:Person
rdf:type owl:Person ..
116
117
118
For example
If:
:Novel
rdf:type
:Novel
rdf:type owl:Class.
owl:Class.
:Short_Story
rdf:type
owl:Class.
:Short_Story
rdf:type owl:Class.
:Poetry
rdf:type
:Poetry
rdf:type owl:Class.
owl:Class.
:Literature
:Literature rdf:type
rdf:type owl:Class;
owl:Class;
owl:unionOf
(:Novel
owl:unionOf (:Novel :Short_Story
:Short_Story :Poetry).
:Poetry).
<myWork>
<myWork> rdf:type
rdf:type :Novel
:Novel ..
119
120
121
122
123
Restrictions formally
:Listed_Price
:Listed_Price rdfs:subClassOf
rdfs:subClassOf [[
rdf:type
owl:Restriction;
rdf:type
owl:Restriction;
owl:onProperty
p:currency;
owl:onProperty
p:currency;
owl:allValuesFrom
:Currency.
owl:allValuesFrom
:Currency.
].
].
124
Possible usage
If:
:Listed_Price
:Listed_Price rdfs:subClassOf
rdfs:subClassOf [[
rdf:type
owl:Restriction;
rdf:type
owl:Restriction;
owl:onProperty
p:currency;
owl:onProperty
p:currency;
owl:allValuesFrom
:Currency.
owl:allValuesFrom
:Currency.
].
].
:price
:price rdf:type
rdf:type :Listed_Price
:Listed_Price ..
:price
:price p:currency
p:currency <something>
<something> ..
125
Other restrictions
someValuesFrom
126
Datatypes in OWL
127
128
129
130
131
OWL species
132
133
etc.
134
OWL DL
135
136
<q>
<q> rdf:type
rdf:type <A>.
<A>.
## AA is
is aa class,
class, qq is
is an
an individual
individual
<r>
<r> rdf:type
rdf:type <q>.
<q>.
## error:
error: qq cannot
cannot be
be used
used for
for aa class,
class, too
too
<A>
<A> ex:something
ex:something <B>.
<B>.
## error:
error: properties
properties are
are for
for individuals
individuals only
only
<q>
<q> ex:something
ex:something <s>.
<s>.
<p>
ex:something
54.
<p> ex:something 54.
## error:
error: same
same property
property cannot
cannot be
be used
used as
as
## object
and
datatype
property
object and datatype property
OWL DL usage
137
138
OWL 2 profiles: EL
Suitable for
eg: SNOMED
139
OWL 2 profiles: QL
Suitable for
140
OWL 2 profiles: RL
Suitable for
141
Ontology development
142
NO!!!
143
Ontologies examples
144
145
146
Prioritization of
drug target,
integrating data
from different
sources and
formats
Integration,
search via
ontologies
(proprietary and
public)
147
Integration of
experience and data in
the planning of deep
sea drilling processes
Discover relevant
experiences
Courtesy of David Norheim and Roar Fjellheim, Computas AS (SWEO Use Case)
148
149
Rules
(RIF)
Rules
150
151
If
If {{ ?x
?x rdf:type
rdf:type p:Novel;
p:Novel;
p:page_number
p:page_number ?p;
?p;
p:price
[
p:price [
p:currency
p:currency p:;
p:;
rdf:value
?z
rdf:value ?z
].
].
?p
?p >> "500"^^xsd:integer.
"500"^^xsd:integer.
?z
<
"5.0"^^xsd:double.
?z < "5.0"^^xsd:double. }}
then
then {{ ?x
?x rdf:type
rdf:type p:CheapBook
p:CheapBook }}
152
153
154
In an ideal World
155
156
157
RIF dialects
158
Role of dialects
159
Role of dialects
160
Role of dialects
161
Role of dialects
162
However
163
Hierarchy of cores
164
Current status
165
RIF Core
Core defines
A Core document is
166
167
Document(
Document(
Prefix(cpt
Prefix(cpt http://example.com/concepts#)
http://example.com/concepts#)
Prefix(ppl
http://example.com/people#)
Prefix(ppl http://example.com/people#)
Prefix(bks
Prefix(bks http://example.com/books#)
http://example.com/books#)
))
Group
Group
((
Forall
Forall ?Buyer
?Buyer ?Item
?Item ?Seller
?Seller ((
cpt:buy(?Buyer
cpt:buy(?Buyer ?Item
?Item ?Seller):?Seller):- cpt:sell(?Seller
cpt:sell(?Seller ?Item
?Item ?Buyer)
?Buyer)
))
cpt:sell(ppl:John
cpt:sell(ppl:John bks:LeRif
bks:LeRif ppl:Mary)
ppl:Mary)
))
p # T
168
169
Rules vs OWL?
170
171
Other SW technologies
172
173
174
175
Integration of
relevant data in
Zaragoza (using
RDF and ontologies)
Courtesy of Jess Fernndez, Mun. of Zaragoza, and Antonio Campos, CTIC (SWEO Use Case)
176
177
http://www.w3.org/2001/sw/
Core vocabularies
178
Some books
179
http://planetrdf.com/
http://www.w3.org/2001/sw/interest/
there are also similar list for Linked Open Data, OWL
developers, etc
180
181
Categories:
Triple Stores
Inference engines
Converters
Search engines
Middleware
CMS
Semantic Web browsers
Development environments
Semantic Wikis
Some names:
Conclusions
182
183
184