Krzysztof Kurzydło Semantic Web – Sprawozdanie 3

Transkrypt

Krzysztof Kurzydło Semantic Web – Sprawozdanie 3
 Krzysztof Kurzydło Semantic Web – Sprawozdanie 3 3. <?xml version="1.0" encoding="UTF-­‐8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#"> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
orwell1984"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Orwell</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Rok 1984</title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
harrypotter"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Joanne Kathleen Rowling</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Harry Potter</title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
gameofthrones"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Raymond Richard Martin</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Game of Thrones</title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
thewitcher"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Andrzej Sapkowski</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Witcher</title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#cd-­‐
hanszimmer_gladiator"> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Gladiator Original Soundtrack</title> <artists rdf:parseType="Collection"> <rdf:Description rdf:about="http://example.org/kkurzydlo#hans-­‐
zimmer"> <name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Hans Zimmer</name> <occupation rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Film Music Composer</occupation> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#lisa-­‐gerrard"> <name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Lisa Gerrard</name> <occupation rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Composer</occ
upation> </rdf:Description> </artists> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#MyFavouriteBooks"> <books> <rdf:Bag> <rdf:li rdf:resource="http://example.org/kkurzydlo#book-­‐
orwell1984"/> <rdf:li rdf:resource="http://example.org/kkurzydlo#book-­‐
harrypotter"/> </rdf:Bag> </books> </rdf:Description> </rdf:RDF> 4. Feedback – aplet ze względu na zabezpieczenia Javy nie był w stanie uruchomić się na moim systemie operacyjnym (Mac OS X). 5. <?xml version="1.0" encoding="UTF-­‐8"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
orwell1984"> <dc:author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Orwell</dc:author> <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Rok 1984</dc:title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
harrypotter"> <dc:author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Joanne Kathleen Rowling</dc:author> <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Harry Potter</dc:title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
gameofthrones"> <dc:author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Raymond Richard Martin</dc:author> <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Game of Thrones</dc:title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
thewitcher"> <dc:author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Andrzej Sapkowski</dc:author> <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Witcher</dc:title> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#cd-­‐
hanszimmer_gladiator"> <dc:title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Gladiator Original Soundtrack</dc:title> <dc:author>Hans Zimmer</dc:creator> <dc:author>Lisa Gerrard</dc:creator> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#MyFavouriteBooks"> <books> <rdf:Bag> <rdf:li rdf:resource="http://example.org/kkurzydlo#book-­‐orwell1984"/> <rdf:li rdf:resource="http://example.org/kkurzydlo#book-­‐harrypotter"/> </rdf:Bag> </books> </rdf:Description> </rdf:RDF> 6. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-­‐schema#" xml:base="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/kkurzydlo#book-­‐
orwell1984"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Orwell</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Rok 1984</title> <rdf:type rdf:resource="http://example.org/mylibrary#Book"/> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
harrypotter"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Joanne Kathleen Rowling</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Harry Potter</title> <rdf:type rdf:resource="http://example.org/mylibrary#Book"/> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
gameofthrones"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">George Raymond Richard Martin</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Game of Thrones</title> <rdf:type rdf:resource="http://example.org/mylibrary#Book"/> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#book-­‐
thewitcher"> <author rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Andrzej Sapkowski</author> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The Witcher</title> <rdf:type rdf:resource="http://example.org/mylibrary#Book"/> </rdf:Description> <rdf:Description rdf:about="http://example.org/kkurzydlo#cd-­‐
hanszimmer_gladiator"> <title rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Gladiator Original Soundtrack</title> <rdf:type rdf:resource="http://example.org/mylibrary#MusicCD"/> </rdf:Description> </rdf:RDF> 7. SPARQL SELECT – umożliwia wydobywanie określonych w zapytaniu danych podobnie jak SELECT języka SQL. CONSTRUCT – wykonuje to samo co SELECT oraz dodatkowo na wyjściu zwraca graf w formacie RDF 8. 8.1. Friends who have name and e-­‐mail defined PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name ?email FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { ?x rdf:type foaf:Person. ?x foaf:name ?name. ?x foaf:mbox_sha1sum ?email. } 8.2. Friends who have name and e-­‐mail defined and optional homepage PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name ?email ?homepage FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { ?x rdf:type foaf:Person . ?x foaf:name ?name. ?x foaf:mbox_sha1sum ?email. OPTIONAL{?x foaf:homepage ?homepage}. } 8.3. Friends who have name and e-­‐mail defined and optional homepage, sorted by name descending PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name ?email ?homepage FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { ?x rdf:type foaf:Person . ?x foaf:name ?name. ?x foaf:mbox_sha1sum ?email. OPTIONAL{?x foaf:homepage ?homepage}. } ORDER BY ?name DESC(?name) 9. 9.1. People whose name starts with 'K' PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { ?x rdf:type foaf:Person. ?x foaf:name ?name. FILTER regex(?name,"^K") } 9.2. People who are older than 18 years old PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE{ ?x rdf:type foaf:Person. ?x foaf:name ?name. ?x foaf:age ?age FILTER (?age>18) } 9.3. People whose name starts with 'K' or are older than 18 years old, make search caseinsensitive. PREFIX rdf: <http://www.w3.org/1999/02/22-­‐rdf-­‐syntax-­‐ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { { ?x rdf:type foaf:Person. ?x foaf:name ?name FILTER regex (?name,"^K","i") } UNION { ?x rdf:type foaf:Person. ?x foaf:age ? age FILTER (?age>18) } } 9.4. People having e-­‐mails on student.agh.edu.pl server PREFIX rdf: <http://www.w3.org/1999/02/22rdfsyntaxns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { ?x rdf:type foaf:Person. ?x foaf:name ?name. ?x foaf:mbox ?email FILTER regex (?email,".*@student\.agh\.edu\.pl$") } 9.5. Name of people, who have homepage or e-­‐mail on student.agh.edu.pl server PREFIX rdf: <http://www.w3.org/1999/02/22rdfsyntaxns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT DISTINCT ?name ?email ?homepage FROM <http://student.agh.edu.pl/~diwi/semweb/lab1/FOAF.xml> WHERE { { ?x rdf:type foaf:Person. ?x foaf:name ?name. ?x foaf:mbox ?email FILTER regex( ?email,".*@student\.agh\.edu\.pl$") } UNION { ?x rdf:type foaf:Person. ?x foaf:homepage ?homepage } }