sprawozdanie
Transkrypt
sprawozdanie
Tomasz Choma
LAB 2 - Modeling and using knowledge in RDF
SPRAWOZDANIE
28.10.2014
1-3
RDF/XML document
Include your RDF/XML document in the report archive.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:tch="http://example.org/mylibrary#">
<rdf:Description rdf:about="http://example.org/mylibrary#book-jkrowling_hp5">
<author>Joanne K. Rowling</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
Harry Potter and the Order of the Phoenix
</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
21-06-2003
</publicationDate>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-nsparks_notebook">
<author>Nicholas Sparks</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Notebook</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
01-10-1996
</publicationDate>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-tolkien_hobbit">
<author>J. R. R. Tolkien</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
The Hobbit, or There and Back Again
</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
21-09-1967
</publicationDate>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#cd-enej_folkhorod">
<artist>Enej</artist>
<tch:members rdf:parseType="Collection">
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PiotrSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_MiroslawOrtynski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PawelSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JacekGrygorowicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JakubCzaplejewicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_LukaszPrzyborowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_DamianPinkowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_KornelKondrak"/>
</tch:members>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Folkhorod</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
16-11-2012
</publicationDate>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#MyFavouriteBooks">
<tch:MyFavouriteBooks>
<rdf:Bag>
<rdf:li rdf:resource="http://example.org/mylibrary#book-jkrowling_hp5"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-nsparks_notebook"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-tolkien_hobbit"/>
</rdf:Bag>
</tch:MyFavouriteBooks>
</rdf:Description>
</rdf:RDF>
4
RDF Visualization
2. Are there any problems/limitations
observations in the report.
with
the
tool?
Write
your
Pojawił się problem z uruchomieniem aplikacji za pomocą pobranego pliku rdfgravity.jnlp wynikający z nieakceptowania certyfikatu aplikacji przez JVM. Problem
udało się rozwiązać, dzięki paczce zip zawierającej wszystkie potrzebne jar-y,
znalezionej na stackoverflow.com.
3. Include the screenshots of your file visualized with RDFGravity (or other
RDF visualization tool if you find one).
5
Semantic vocabularies: Dublin Core
Modify the file to include it in the report.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:tch="http://example.org/mylibrary#">
<rdf:Description rdf:about="http://example.org/mylibrary#book-jkrowling_hp5">
<dc:author>Joanne K. Rowling</dc:author>
<dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
Harry Potter and the Order of the Phoenix
</dc:title>
<dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">21-06-2003</dc:date >
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-nsparks_notebook">
<dc:author>Nicholas Sparks</dc:author>
<dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Notebook</dc:title>
<dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">01-10-1996</dc:date>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-tolkien_hobbit">
<dc:author>J. R. R. Tolkien</dc:author>
<dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
The Hobbit, or There and Back Again
</dc:title>
<dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">21-09-1967</dc:date>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#cd-enej_folkhorod">
<artist>Enej</artist>
<tch:members rdf:parseType="Collection">
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PiotrSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_MiroslawOrtynski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PawelSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JacekGrygorowicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JakubCzaplejewicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_LukaszPrzyborowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_DamianPinkowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_KornelKondrak"/>
</tch:members>
<dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Folkhorod</dc:title>
<dc:date rdf:datatype="http://www.w3.org/2001/XMLSchema#date">16-11-2012</dc:date>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#MyFavouriteBooks">
<tch:MyFavouriteBooks>
<rdf:Bag>
<rdf:li rdf:resource="http://example.org/mylibrary#book-jkrowling_hp5"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-nsparks_notebook"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-tolkien_hobbit"/>
</rdf:Bag>
</tch:MyFavouriteBooks>
</rdf:Description>
</rdf:RDF>
6
RDFSchema
Modify the file to include it in the report.
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:tch="http://example.org/mylibrary#">
<rdfs:Class rdf:ID="MultimediaItem"/>
<rdfs:Class rdf:ID="MusicCD">
<rdfs:subClassOf rdf:resource="#MultimediaItem"/>
<rdfs:label>Music Compact Discs class</rdfs:label>
<rdfs:comment>Class of all the CDs in my library.</rdfs:comment>
</rdfs:Class>
<rdfs:Class rdf:ID="Book">
<rdfs:subClassOf rdf:resource="#MultimediaItem"/>
<rdfs:label>Books class</rdfs:label>
<rdfs:comment>Class of all the books in my library.</rdfs:comment>
</rdfs:Class>
<rdf:Description rdf:about="http://example.org/mylibrary#book-jkrowling_hp5">
<author>Joanne K. Rowling</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
Harry Potter and the Order of the Phoenix
</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
21-06-2003
</publicationDate>
<rdf:type rdf:resource="http://example.org/mylibrary#Book"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-nsparks_notebook">
<author>Nicholas Sparks</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Notebook</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
01-10-1996
</publicationDate>
<rdf:type rdf:resource="http://example.org/mylibrary#Book"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#book-tolkien_hobbit">
<author>J. R. R. Tolkien</author>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
The Hobbit, or There and Back Again
</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
21-09-1967
</publicationDate>
<rdf:type rdf:resource="http://example.org/mylibrary#Book"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#cd-enej_folkhorod">
<artist>Enej</artist>
<tch:members rdf:parseType="Collection">
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PiotrSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_MiroslawOrtynski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_PawelSoloducha"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JacekGrygorowicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_JakubCzaplejewicz"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_LukaszPrzyborowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_DamianPinkowski"/>
<rdf:Description rdf:about="http://example.org/mylibrary#EnejMembers_KornelKondrak"/>
</tch:members>
<title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Folkhorod</title>
<publicationDate rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
16-11-2012
</publicationDate>
<rdf:type rdf:resource="http://example.org/mylibrary#MusicCD"/>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/mylibrary#MyFavouriteBooks">
<tch:MyFavouriteBooks>
<rdf:Bag>
<rdf:li rdf:resource="http://example.org/mylibrary#book-jkrowling_hp5"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-nsparks_notebook"/>
<rdf:li rdf:resource="http://example.org/mylibrary#book-tolkien_hobbit"/>
</rdf:Bag>
</tch:MyFavouriteBooks>
</rdf:Description>
</rdf:RDF>
7
SPARQL - demo
5. What do SELECT queries do?
SELECT zwraca wartości zmiennych związanych w dopasowaniu wzoru zapytania.
6. What do CONSTRUCT queries do?
CONSTRUCT pozwala na transformację grafów RDF.
8
SPARQL queries - basics
friends who have name and e-mail defined
SELECT DISTINCT ?name ?email
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:mbox ?email
}
friends who have name and e-mail defined and optional homepage
SELECT DISTINCT ?name ?email ?homepage
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:mbox ?email .
OPTIONAL{?x foaf:homepage ?homepage}
}
frends who have name and e-mail defined and optional homepage, sorted
by name descending
SELECT DISTINCT ?name ?email ?homepage
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:mbox ?email .
OPTIONAL{?x foaf:homepage ?homepage}
}
ORDER BY DESC(?name)
9
SPARQL queries - options
people whose name starts with 'K'
SELECT DISTINCT ?name
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name
FILTER regex(?name, "^K")
}
people who are older than 18 years old
SELECT DISTINCT ?name ?age
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:age ?age
FILTER(?age > 18)
}
people whose name starts with 'K' or are older than 18 years old, make
search caseinsensitive
SELECT DISTINCT ?name ?age
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:age ?age
FILTER (regex(?name, "^[Kk]") || ?age > 18)
}
people having e-mails on student.agh.edu.pl server
SELECT DISTINCT ?name ?email
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:mbox ?email
FILTER regex(str(?email), "@student.agh.edu.pl")
}
name of people, who have homepage or e-mail on student.agh.edu.pl
server
SELECT DISTINCT ?name
WHERE {
?x rdf:type foaf:Person .
?x foaf:name ?name .
?x foaf:mbox ?email .
?x foaf:homepage ?homepage
FILTER (regex(str(?email), "@student.agh.edu.pl")
|| regex(str(?homepage), "student.agh.edu.pl"))
}