Podstawy In»ynierii Wiedzy - Semantic Web Sprawozdanie 3

Transkrypt

Podstawy In»ynierii Wiedzy - Semantic Web Sprawozdanie 3
Podstawy In»ynierii Wiedzy - Semantic Web
Sprawozdanie 3
Andrzej Kieªtyka, Aleksandra Sikora
22 ma ja 2012
1
Resource Description Framework (RDF) in use
1.1 Semantic vocabularies: Dublin Core & RDFSchema
xml version
DOCTYPE
1 <?
=" 1 . 0 "
2 <!
3
rdf:RDF
−8" ?>
−//DUBLIN CORE/ /DCMES
e n c o d i n g="UTF
PUBLIC
"
DTD
2 0 0 2 / 0 7 / 3 1 / /EN"
" h t t p : / / d u b l i n c o r e . o r g / d o c u m e n t s / 2 0 0 2 / 0 7 / 3 1 / dcmes
−xml / dcmes−xml−d t d . d t d
">
4 <r d f : R D F
− r d f −s y n t a x −n s#"
−s c h e m a#"
5
x m l n s : r d f=" h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
6
x m l n s : r d f s=" h t t p : / /www . w3 . o r g / 2 0 0 0 / 0 1 / r d f
7
xmlns:dc
8
x m l n s=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#">
=" h t t p : / / p u r l . o r g / d c / e l e m e n t s / 1 . 1 / "
9
10
<r d f s : C l a s s
r d f : I D=" M u l t i m e d i a I t e m " />
11
<r d f s : C l a s s
r d f : I D=" Book ">
12
<r d f s : s u b C l a s s O f
13
< r d f s : l a b e l >B o o k s
14
<r d f s : c o m m e n t> C l a s s
15
</ r d f s : C l a s s>
16
<r d f s : C l a s s
r d f : r e s o u r c e ="#M u l t i m e d i a I t e m " />
c l a s s</ r d f s : l a b e l >
of
all
the
books
in
our
l i b r a r y .</ r d f s : c o m m e n t>
r d f : I D="Game">
17
<r d f s : s u b C l a s s O f
18
< r d f s : l a b e l >Computer
r d f : r e s o u r c e ="#M u l t i m e d i a I t e m " />
19
<r d f s : c o m m e n t> C l a s s
games
of
all
c l a s s</ r d f s : l a b e l >
the
PC
games
in
our
l i b r a r y .</
r d f s : c o m m e n t>
20
</ r d f s : C l a s s>
21
22
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
p e r f ">
23
<d c : c r e a t o r
Jacek
24
<d c : t i t l e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
D u k a j</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Perfekcyjna
25
<d c : p u b l i s h e r
26
<d c : d a t e
n i e d o s k o n a l o s c</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">Wydawnictwo
L i t e r a c k i e</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 4</ d c : d a t e>
1
27
<d c : l a n g u a g e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
28
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
29
</ r d f : D e s c r i p t i o n>
30
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
l o d ">
31
<d c : c r e a t o r
Jacek
32
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
D u k a j</ d c : c r e a t o r>
<d c : t i t l e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Lod</ d c : t i t l e >
33
<d c : p u b l i s h e r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">Wydawnictwo
34
<d c : d a t e
35
<d c : l a n g u a g e
L i t e r a c k i e</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 7</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
36
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
37
</ r d f : D e s c r i p t i o n>
38
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
o c e a n y ">
39
<d c : c r e a t o r
Jacek
40
<d c : t i t l e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Czarne
41
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
D u k a j</ d c : c r e a t o r>
o c e a n y</ d c : t i t l e >
<d c : p u b l i s h e r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">superNOWA</ d c : p u b l i s h e r>
42
<d c : d a t e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 1</ d c : d a t e>
43
<d c : l a n g u a g e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
44
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
45
</ r d f : D e s c r i p t i o n>
46
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
k r o l ">
47
<d c : c r e a t o r
Jacek
48
<d c : t i t l e
Krol
49
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
D u k a j</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
B o l u</ d c : t i t l e >
<d c : p u b l i s h e r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">Wydawnictwo
50
<d c : d a t e
51
<d c : l a n g u a g e
L i t e r a c k i e</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 1 0</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
52
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
53
</ r d f : D e s c r i p t i o n>
54
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
n i e g r z e s z n y ">
2
−
55
<d c : c r e a t o r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Eugeniusz
D e b s k i</ d c : c r e a t o r>
56
<d c : t i t l e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
57
<d c : p u b l i s h e r
58
<d c : d a t e
59
<d c : l a n g u a g e
Niegrzeszny
mag</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">F a b r y k a
S l o w</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 7</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
60
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
61
</ r d f : D e s c r i p t i o n>
62
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
o g r o d 1 ">
63
<d c : c r e a t o r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Jaroslaw
G r z e d o w i c z</ d c : c r e a t o r>
64
<d c : t i t l e
65
<d c : p u b l i s h e r
66
<d c : d a t e
67
<d c : l a n g u a g e
Pan
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Lodowego
Ogrodu
−
tom
1</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">F a b r y k a
S l o w</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 5</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
68
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
69
</ r d f : D e s c r i p t i o n>
70
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
d r o g a ">
71
<d c : c r e a t o r
Howar
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Phillips
72
<d c : t i t l e
73
<d c : p u b l i s h e r
Droga
do
">Z y s k
74
<d c : d a t e
L o v e c r a f t</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
s z a l e n s t w a</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
−k a</ d c : p u b l i s h e r>
i
S
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 4</ d c : d a t e>
75
<d c : l a n g u a g e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
76
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
77
</ r d f : D e s c r i p t i o n>
78
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
a n i s l o w a ">
79
<d c : c r e a t o r
Jacek
80
<d c : t i t l e
Ani
81
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
P i e k a r a</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
slowa
<d c : p u b l i s h e r
prawdy</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">Runa</ d c : p u b l i s h e r>
82
<d c : d a t e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 5</ d c : d a t e>
3
83
<d c : l a n g u a g e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
84
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
85
</ r d f : D e s c r i p t i o n>
86
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
c a r p e ">
87
<d c : c r e a t o r
Terry
88
<d c : t i t l e
Carpe
89
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
P r a t c h e t t</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Jugulum</ d c : t i t l e >
<d c : p u b l i s h e r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
"> P r o s z y n s k i
90
<d c : d a t e
91
<d c : l a n g u a g e
i
−k a</ d c : p u b l i s h e r>
S
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 6</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
92
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
93
</ r d f : D e s c r i p t i o n>
94
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
c o s k o n c z y ">
95
<d c : c r e a t o r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Andrzej
96
<d c : t i t l e
Cos
S a p k o w s k i</ d c : c r e a t o r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
sie
konczy ,
97
<d c : p u b l i s h e r
98
<d c : d a t e
cos
sie
z a c z y n a</ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
">superNOWA</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
2 0 0 0</ d c : d a t e>
99
<d c : l a n g u a g e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
100
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
101
</ r d f : D e s c r i p t i o n>
102
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#book
−
omen ">
103
<A u t h o r s
r d f : p a r s e T y p e=" C o l l e c t i o n ">
104
<r d f : D e s c r i p t i o n
r d f : P r o p e r t y=" T e r r y
105
<r d f : D e s c r i p t i o n
r d f : P r o p e r t y=" N e i l
106
</ A u t h o r s>
107
<d c : t i t l e
Dobry
108
P r a t c h e t t " />
Gaiman " />
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
omen</ d c : t i t l e >
<d c : p u b l i s h e r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
"> P r o s z y n s k i
109
<d c : d a t e
110
<d c : l a n g u a g e
i
−k a</ d c : p u b l i s h e r>
S
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
1 9 9 7</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
111
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Book " /
>
112
</ r d f : D e s c r i p t i o n>
113
4
114
−
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#game
d3 ">
115
<d c : c r e a t o r
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
Blizzard
E n t e r t a i n m e n t</ d c : c r e a t o r>
116
<d c : t i t l e
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g ">
117
<d c : p u b l i s h e r
Diablo
I I I </ d c : t i t l e >
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#s t r i n g
"> B l i z z a r d
118
<d c : d a t e
119
<d c : l a n g u a g e
2012
E n t e r t a i n m e n t</ d c : p u b l i s h e r>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#g d c : d a t e ">
− 05 − 15</ d c : d a t e>
r d f : d a t a t y p e=" h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#
g d c : d a t e "> p l</ d c : l a n g u a g e>
120
<r d f : t y p e
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#Game" /
>
121
</ r d f : D e s c r i p t i o n>
122
123
<r d f : D e s c r i p t i o n
r d f : a b o u t=" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#
f a v b o o k s ">
124
<M y F a v o u r i t e B o o k s>
125
< r d f : B a g>
126
<r d f : l i
book
127
<r d f : l i
book
128
<r d f : l i
book
129
130
131
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#
−c a r p e " />
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#
−o c e a n y " />
r d f : r e s o u r c e =" h t t p : / / p i w . l a b 2 . a g h . e d u . p l / m y l i b r a r y#
− p e r f " />
</ r d f : B a g>
</ M y F a v o u r i t e B o o k s>
</ r d f : D e s c r i p t i o n>
132 </ r d f : R D F>
1.2 SPARQL - demo
• What semantic vocabularies are used in the queries? What are they for?
rdf - ogólnego zastosowania, reprezentowanie informacji,
foaf - ª¡czenie ludzi i informacji,
dc, dct - opisywanie zasobów,
sioc - opisywanie informacji z miejsc takich jak fora internetowe, blogi, listy
mailingowe etc.,
owl - ontologie,
rss - kanaªy RSS, teksty podsumowuj¡ce wraz z pewnymi metadanymi,
rev - recenzje i oceny,
prj - opisywanie projektów niezale»nie od ich dziedziny,
tag - do opisu tagów, takich jak te u»ywane przez np. del.icio.us czy Flicker,
i zale»no±ci mi¦dzy nimi.
5
• What do SELECT queries do?
SELECT zwraca zmienne oraz ich bezpo±rednie powi¡zania w formie tabeli.
• What do CONSTRUCT queries do?
CONSTRUCT zwraca graf RDF okre±lony przez wzorzec.
1.3 SPARQL queries - basics
• friends who have name and e-mail dened
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3
4
5
6
7
SELECT
FROM
WHERE
? name
? mail
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
8
?x
9
10
r d f : type
f o a f : Person
f o a f : knows
? friend
? friend
11
12
− r d f −s y n t a x −n s#>
;
.
f o a f : name
? name
;
f o a f : mbox
? mail
.
}
• friends who have name and e-mail dened and optional homepage
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3
4
5
6
7
SELECT
FROM
WHERE
? name
?www
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
8
?x
9
10
r d f : type
f o a f : Person
f o a f : knows
? friend
? friend
11
12
13
? mail
− r d f −s y n t a x −n s#>
;
.
f o a f : name
? name
;
f o a f : mbox
? mail
.
OPTIONAL
{
? friend
f o a f : homepage
?www
}
}
• friends who have name and e-mail dened and optional homepage, sorted by name
descending
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3
4
5
6
7
8
9
10
SELECT
FROM
WHERE
? name
? mail
?www
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
?x
− r d f −s y n t a x −n s#>
r d f : type
f o a f : Person
f o a f : knows
? friend
? friend
f o a f : name
;
.
? name
;
6
11
f o a f : mbox
12
13
14
OPTIONAL
{
? friend
? mail
.
f o a f : homepage
?www
}
}
ORDER BY DESC
( ? name )
1.4 SPARQL queries - options
• people whose name starts with 'K'
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3
4
5
6
7
SELECT
FROM
WHERE
? name
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
8
? person
9
10
11
− r d f −s y n t a x −n s#>
FILTER
r d f : type
f o a f : Person
f o a f : name
? name
;
.
r e g e x ( ? name , ' ^K ' )
}
• people who are older than 18 years old
− r d f −s y n t a x −n s#>
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3 PREFIX
xsd :
<h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#>
4
5
6
7
8
SELECT
FROM
WHERE
? name
{
9
? person
10
11
12
13
? age
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
FILTER
r d f : type
f o a f : Person
f o a f : name
? name
f o a f : age
? age
(
xsd :
decimal
;
;
.
(? age )
>
18
)
}
• people whose name starts with 'K' or are older than 18 years old, make search
caseinsensitive
− r d f −s y n t a x −n s#>
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3 PREFIX
xsd :
<h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#>
4
5
6
7
8
9
SELECT
FROM
WHERE
? name
? age
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
r d f : type
f o a f : Person
10
? person
f o a f : name
? name
11
f o a f : age
? age
;
;
.
7
12
13
FILTER
(
r e g e x ( ? name , ' ^k ' , ' i ' )
&&
xsd :
decimal
(? age )
>
18
)
}
• people having e-mails on student.agh.edu.pl server
− r d f −s y n t a x −n s#>
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3 PREFIX
xsd :
<h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#>
4
5
6
7
8
SELECT
FROM
WHERE
? name
{
9
? person
10
11
12
13
? mail
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
FILTER
r d f : type
f o a f : Person
f o a f : name
? name
;
f o a f : mbox
? mail
.
;
r e g e x ( x s d : s t r i n g ( ? m a i l ) , ' @ s t u d e n t . agh . edu . p l $ ' )
}
• name of people, who have homepage or e-mail on student.agh.edu.pl server
− r d f −s y n t a x −n s#>
1 PREFIX
rdf :
<h t t p : / /www . w3 . o r g / 1 9 9 9 / 0 2 / 2 2
2 PREFIX
foaf :
<h t t p : / / x m l n s . com/ f o a f / 0 . 1 / >
3 PREFIX
xsd :
<h t t p : / /www . w3 . o r g / 2 0 0 1 / XMLSchema#>
4
5
6
7
8
SELECT
FROM
WHERE
? name
? mail
?www
<h t t p : / / s t u d e n t . a g h . e d u . p l /~ o l a / f o a f . h t m l>
{
9
r d f : type
f o a f : Person
10
? person
f o a f : name
? name
11
f o a f : mbox
? mail
12
f o a f : homepage
?www
13
FILTER
(
;
;
;
.
r e g e x ( x s d : s t r i n g ( ? m a i l ) , ' @ s t u d e n t . agh . edu . p l $ ' )
x s d : s t r i n g ( ?www) , ' ^ h t t p : / / s t u d e n t . a g h . e d u . p l / ' )
14
||
regex (
)
}
1.5 Open Data Sets
• What are the main limitations of using (querying for information) the RDF datasets
such as DBPedia or MusicBrainz?
wymagana znajomo±¢ j¦zyka zapyta« SPARQL, co dla przeci¦tnego u»yszkodnika Internetu mo»e by¢ barier¡ nie do przeskoczenia,
wymagana znajomo±¢ sªowników semantycznych, które opisuj¡ interesuj¡ce
nas dane, aby móc napisa¢ poprawne zapytanie SPARQL, czyli kolejne utrudnienie w stosunku do chocia»by Wikipedii czy Google,
czas potrzebny do uzyskania odpowiedzi przy bardziej skomplikowanych zapytaniach b¡d¹ w przypadku operowania na wi¦kszych zbiorach danych.
8