Άσκηση RDF Schema Να επεκτείνετε το RDF Schema της ερώτησης 4 με σκοπό να αναπαραστήσετε την παρακάτω γνώση: «Ο Εκδότης εκδίδει Βιβλία». Να ορίσετε νέες κλάσεις και ιδιότητες αν χρειαστεί, συσχετίζοντάς τες όσο το δυνατόν καλύτερα με τις υπάρχουσες. Μετά να ορίσετε έναν νέο εκδότη με το ID book:penguin_pub ο οποίος εκδίδει το βιβλίο book:book20. Μπορείτε να χρησιμοποιήσετε είτε RDF/XML είτε RDF/N-triples. Απάντηση: <rdfs:class rdf:id="#publisher"> <rdfs:subclassof rdf:resource="#person"/> <rdf:property rdf:id="publishes"> <rdfs:domain rdf:resource="#publisher"/> <rdfs:range rdf:resource="#book"/> <book:publisher rdf:id="penguin_pub"> <book:publishes rdf:resource="#book20"/> </book:publisher>
Άσκηση SPARQL Γράψτε ένα ερώτημα SPARQL το οποίο να επιστρέφει τα βιβλία που αγόρασε κάποιος με το όνομα John Smith και τους συγγραφείς των βιβλίων αυτών. Χρησιμοποιήστε το RDF έγγραφο του ερωτήματος 4. Ποια είναι η απάντηση στην παραπάνω ερώτηση εάν η βάση δεδομένων RDF (i) υλοποιεί τη σημασιολογία RDFS ή (ii) δεν υλοποιεί τη σημασιολογία RDFS. Υποδειγματικό ερώτημα SPARQL: SELECT?x?y WHERE {?x rdf:type book:book.?x book:price?y. FILTER (?y > 130) } Απάντηση: SELECT?y?z WHERE {?x rdf:type book:customer.?x book:name "John Smith".?x book:hasboughtproduct?y.?y rdf:type book:book.?y book:author?z. } (i) (ii) &book;author21, &book;author23 &book;author23
Άσκηση SWRL Εξηγήστε σύντομα ποιο είναι το νόημα του παρακάτω κανόνα SWRL και ποιο θα είναι το αποτέλεσμά του στην οντολογία του ερωτήματος 5. Book(?x) hasreview(?x,?y) Review (?y) rating(?y,?z) swrlb:greaterthan(?z, 3) BestSeller(?x) Απάντηση Ο παραπάνω κανόνας ορίζει ότι όταν ένα βιβλίο έχει κριτικές με rating πάνω από 3, τότε θεωρείται Best Seller, δηλαδή κατηγοριοποιείται στην κλάση BestSeller. Η κλάση αυτή δεν υπάρχει στην οντολογία, αλλά υποθέτουμε ότι για να μπορέσει να εκτελεστεί ο παραπάνω κανόνας έχει προστεθεί. Στην συγκεκριμένη οντολογία μόνο το Book1 έχει ως review το Review1 το οποίο έχει rating 4, άρα για το βιβλίο αυτό θα ενεργοποιηθεί ο κανόνας και το Book1 θα γίνει classify στην κλάση BestSeller.
Το RDF file της ερώτησης 4 <!DOCTYPE rdf:rdf [ <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!ENTITY book 'http://www.bookstore.org#'> <!ENTITY rdfs 'http://www.w3.org/tr/1999/pr-rdf-schema-19990303#'> <!ENTITY xsd "http://www.w3.org/2001/xmlschema#"> ]> <rdf:rdf xmlns:rdf="&rdf;" xmlns:rdfs="&rdfs;" xmlns:book="&book;"> <rdfs:class rdf:about="&book;person"/> <rdfs:class rdf:about="&book;author"> <rdfs:subclassof rdf:resource="&book;person"/> <rdfs:class rdf:about="&book;customer"> <rdfs:subclassof rdf:resource="&book;person"/> <rdfs:class rdf:about="&book;product"/> <rdfs:class rdf:about="&book;book"> <rdfs:subclassof rdf:resource="&book;product"/> <rdf:property rdf:about="&book;author"> <rdfs:range rdf:resource="&book;author"/> <rdf:property rdf:about="&book;contactauthor"> <rdfs:range rdf:resource="&book;author"/> <rdfs:subpropertyof rdf:resource="&book;author"/> <rdf:property rdf:about="&book;hasboughtproduct"> <rdfs:domain rdf:resource="&book;customer"/> <rdfs:range rdf:resource="&book;product"/> <rdf:property rdf:about="&book;name"> <rdfs:domain rdf:resource="&book;person"/> <rdfs:range rdf:resource="&xsd;string"/> <rdf:property rdf:about="&book;price"> <rdfs:domain rdf:resource="&book;product"/> <rdfs:range rdf:resource="&xsd;decimal"/> <rdf:property rdf:about="&book;title"> <rdfs:domain rdf:resource="&book;product"/> <rdfs:range rdf:resource="&xsd;string"/> <rdf:property rdf:about="&book;year"> <rdfs:range rdf:resource="&xsd;integer"/> <book:book rdf:about="&book;book20"> <book:price rdf:datatype="&xsd;decimal">130.0</book:price> <book:title rdf:datatype="&xsd;string">parallel, Object-Oriented, and Active Knowledge Base Systems</book:title> <book:year rdf:datatype="&xsd;integer">2002</book:year> <book:contactauthor rdf:resource="&book;author21"/> <book:author rdf:resource="&book;author23"/> </book:book> <book:author rdf:about="&book;author21"> <book:name rdf:datatype="&xsd;string">nick Bassiliades</book:name> </book:author> <book:customer rdf:about="&book;customer24"> <book:name rdf:datatype="&xsd;string">john Smith</book:name> <book:hasboughtproduct rdf:resource="&book;book20"/> <book:hasboughtproduct rdf:resource="&book;book21"/> </book:customer> </rdf:rdf>
Η οντολογία της ερώτησης 5 σε Manchester syntax Class: Person Class: Product Class: Review Class: Customer SubClassOf: Person Class: DVD Class: Author Class: BadReview SubClassOf: Product SubClassOf: Person SubClassOf: Review, rating value "0"^^xsd:int Class: Bibliophile Class: BadReviewer SubClassOf: Customer, hasbought only Book SubClassOf: Person, hasreviewed some BadReview Class: SingleAuthoredBook SubClassOf: Book, author max 1 owl:thing Class: Book SubClassOf: Product, author min 1 owl:thing ObjectProperty: hasreview Characteristics: InverseFunctional Range: Review InverseOf: aboutbook ObjectProperty: hasbought Domain: Customer Range: Product DataProperty: content Domain: DVD DataProperty: name Domain: Person Individual: Customer1 Types: Bibliophile hasbought Book1, hasbought DVD1 hasreviewed Review1, hasreviewed Review2, name "Smith" Individual: Author1 haswritten Book1, name "Vlahavas" Individual: DVD1 Types: DVD content "Movie", price "30"^^xsd:int, title "Startrek" Individual: Person1 Types: BadReviewer name "Lucas" ObjectProperty: hasreviewed Characteristics: InverseFunctional Domain: Person Range: Review InverseOf: reviewby ObjectProperty: haswritten Domain: Author Range: Book InverseOf: author DataProperty: text DataProperty: year Range: xsd:gyear Individual: Book2 author Author3, hasreview Review2, price "45"^^xsd:int, title "Semantic Web", year "2004"^^xsd:gYear Individual: Author2 haswritten Book1, haswritten Book4, name "Bassiliades" Individual: Review2 Types: BadReview aboutbook Book2, reviewby Customer1, text "Not nice" ObjectProperty: reviewby Range: Person InverseOf: hasreviewed ObjectProperty: author Range: Author InverseOf: haswritten DataProperty: title Domain: Product ObjectProperty: contactauthor SubPropertyOf: author Range: Author ObjectProperty: aboutbook Range: Book InverseOf: hasreview DataProperty: price Domain: Product Range: xsd:int DataProperty: rating Range: {"0"^^xsd:int, "1"^^xsd:int, "2"^^xsd:int, "3"^^xsd:int, "4"^^xsd:int, "5"^^xsd:int} Individual: Book1 author Author1, author Author2, contactauthor Author1, hasreview Review1, price "55"^^xsd:int, title "Artificial Intelligence", year "2005"^^xsd:gYear Individual: Book3 price "47"^^xsd:int, title "XML Schema", year "2002"^^xsd:gYear Individual: Review3 Types: BadReview rating "2"^^xsd:int, text "So and so" Individual: Review1 Types: Review aboutbook Book1, reviewby Customer1, rating "4"^^xsd:int, text "Nice Book!" Individual: Book4 Types: SingleAuthoredBook author Author2, author Author3, title "RDF simple" Individual: Author3 haswritten Book2, name "Antoniou"