Download presentation
Presentation is loading. Please wait.
Published byDevyn Buttram Modified over 9 years ago
1
Ontology Engineering Lab #8 October 21, 2013
2
Review - Trial Query Exercises What are the bones of the foot? (not sure this can be done in a single query, explore but do not spend time beyond a reasonable limit) What types of things are the parts of the knee joint? What are the parts of the heart and if they exist how are these parts defined? What are the documented relationships between the Right Adrenal Gland and the Right Kidney? 2
3
Exploring DBPedia DBPedia is a structured store of information from Wikipedia. (see http://en.wikipedia.org/wiki/DBpedia for a summary)http://en.wikipedia.org/wiki/DBpedia SPARQL endpoint can be found at: http://dbpedia.org/sparql http://dbpedia.org/sparql Pages for individual resources can be found at: http://dbpedia.org/page/...... http://dbpedia.org/page/
4
Keystroke Shortcuts Using “;” to repeat the subject term over a set of statements in a where clause SELECT ?city ?faculty ?students WHERE { dbpedia-owl:city ?city ; dbpedia-owl:facultySize ?faculty ; dbpedia-owl:numberOfStudents ?students. }
5
Keystroke Shortcuts Using “,” to repeat the subject and predicate over a set of statements in a where clause SELECT ?abstract_1 ?abstract_2 WHERE { dbpedia-owl:abstract ?abstract_1, ?abstract_2. FILTER (lang(?abstract_1) = "en"). FILTER (lang(?abstract_2) = "zh"). }
6
Different Uses of the Keyword: “OPTIONAL” The following query returns public universities that have both a Forbes rating and a Kiplinger rating: SELECT ?university ?forbes_rating ?kiplinger_rating WHERE { ?university dbpedia-owl:type dbpedia:Public_university. ?university dbpprop:forbes ?forbes_rating. ?university dbpprop:kiplinger ?kiplinger_rating. } LIMIT 100
7
Different Uses of the Keyword: “OPTIONAL” This query returns public universities and their Forbes rating and Kiplinger rating if they have them both: SELECT ?university ?forbes_rating ?kiplinger_rating WHERE { ?university dbpedia-owl:type dbpedia:Public_university. OPTIONAL {?university dbpprop:forbes ?forbes_rating. ?university dbpprop:kiplinger ?kiplinger_rating }. } LIMIT 100
8
Different Uses of the Keyword: “OPTIONAL” This query returns public universities and their Forbes rating and Kiplinger rating if they have either of them: SELECT ?university ?forbes_rating ?kiplinger_rating WHERE { ?university dbpedia-owl:type dbpedia:Public_university. OPTIONAL {?university dbpprop:forbes ?forbes_rating }. OPTIONAL {?university dbpprop:kiplinger ?kiplinger_rating }. } LIMIT 100
9
Different Uses of the Keyword: “OPTIONAL” This query returns public universities and their Kiplinger rating if they have one else it will return their Forbes rating if they have one: SELECT ?university ?rating WHERE { ?university dbpedia-owl:type dbpedia:Public_university. OPTIONAL {?university dbpprop:kiplinger ?rating }. OPTIONAL {?university dbpprop:forbes ?rating }. } LIMIT 100
10
The FILTER Keyword Up to this point we’ve restricted the result set of a query by binding a variable to a class using some object property. For example, the second statement of the following where clause “filters” the result set to public universities in New York State: SELECT ?university WHERE { ?university dbpedia-owl:type dbpedia:Public_university. ?university dbpedia-owl:state dbpedia:New_York. } LIMIT 100
11
The FILTER Keyword The FILTER keyword enables filtering on string and numeric values. The following SELECT query returns public universities that have “business” somewhere in the english label. SELECT ?university ?label WHERE { ?university dbpedia-owl:type dbpedia:Public_university. ?university rdfs:label ?label. FILTER regex(?label, "business", "i"). FILTER (lang(?label)= "en"). } LIMIT 100
12
The FILTER Keyword The following SELECT query returns public universities that have enrollments of more than 60,000. SELECT ?university ?students WHERE { ?university dbpedia-owl:type dbpedia:Public_university. ?university dbpedia-owl:numberOfStudents ?students. FILTER (?students > 60000). } LIMIT 100
13
The FILTER Keyword The following SELECT query returns public universities located in latitudes between 51 and 52 degrees and in longitudes between -1 and 1 degrees. SELECT ?university ?latitude ?longitude WHERE { ?university dbpedia-owl:type dbpedia:Public_university. ?university geo:lat ?latitude. ?university geo:long ?longitude. FILTER (?latitude > 51 && ?latitude < 52). FILTER (?longitude > -1 && ?longitude < 1). } LIMIT 100
14
The FILTER Keyword The following SELECT query returns public companies that have revenues of more than 1 billion (US dollars) or equity of more than 100 billion (US dollars) SELECT ?company ?int_revenue ?int_equity WHERE { ?company dbpedia-owl:type dbpedia:Public_company. ?company dbpedia-owl:revenue ?revenue. ?company dbpedia-owl:equity ?equity. FILTER (datatype(?revenue) = ). BIND(xsd:integer(?revenue) as ?int_revenue). BIND(xsd:integer(?equity) as ?int_equity). FILTER (?int_revenue > 1000000000 || ?int_equity > 100000000000) } LIMIT 100
15
The Filter Keyword The following SELECT query uses the FILTER keyword, logical operator ! and the bound function to return countries that do not have an associated name of their leader SELECT ?country ?leader_name WHERE { ?country rdf:type dbpedia-owl:Country. OPTIONAL {?country dbpedia-owl:leaderName ?leader_name }. FILTER(!bound(?leader_name)). } LIMIT 100
16
Appendix: Answers to Trial Query Exercises What are the bones of the foot? PREFIX fma: PREFIX rdf: PREFIX rdfs: PREFIX owl: SELECT DISTINCT ?set_of_foot_bones ?bones_of_foot ?bones_of_foot_2 WHERE { fma:Skeleton_of_right_foot fma:member ?set_of_foot_bones. OPTIONAL {?set_of_foot_bones fma:member ?bones_of_foot }. OPTIONAL {?bones_of_foot fma:member ?bones_of_foot_2 }. }
17
Appendix: Answers to Trial Query Exercises What are the bones of the foot? PREFIX fma: PREFIX rdf: PREFIX rdfs: PREFIX owl: SELECT DISTINCT ?foot_part WHERE { { fma:Right_foot fma:constitutional_part ?foot_part. ?foot_part fma:articulates_with ?articulate.} UNION { fma:Right_foot fma:constitutional_part ?foot_part_1. ?foot_part_1 fma:articulates_with ?foot_part.} UNION { fma:Right_foot fma:constitutional_part ?foot_part_1. ?foot_part_1 fma:articulates_with ?foot_part_2. ?foot_part_2 fma:articulates_with ?foot_part.} UNION { fma:Right_foot fma:constitutional_part ?foot_part_1. foot_part_1 fma:articulates_with ?foot_part_2. ?foot_part_2 fma:articulates_with ?foot_part_3. ?foot_part_3 fma:articulates_with ?foot_part.} }
18
Appendix: Answers to Trial Query Exercises What types of things are the parts of the knee joint? PREFIX fma: PREFIX rdf: PREFIX rdfs: PREFIX owl: SELECT ?joint_part_type ?part_of_knee_joint WHERE { fma:Knee_joint fma:constitutional_part ?part_of_knee_joint. ?part_of_knee_joint a ?joint_part_type. } ORDER BY ?joint_part_type Most query interfaces allow the use of “a” as an abbreviation for rdf:type. The ORDER BY clause can be used to arrange the result set in order of one or more of the result set variables.
19
Appendix: Answers to Trial Query Exercises What are the parts of the heart and if they exist how are these parts defined? PREFIX fma: PREFIX rdf: PREFIX rdfs: PREFIX owl: SELECT ?part_of_heart ?definition WHERE { fma:Heart fma:constitutional_part ?part_of_heart. OPTIONAL {?part_of_heart fma:definition ?definition }. }
20
Appendix: Answers to Trial Query Exercises What are the documented relationships between the right adrenal gland and the right kidney? PREFIX fma: PREFIX rdf: PREFIX rdfs: PREFIX owl: SELECT ?p1 ?intermediary_1 ?p2 ?intermediary_2 ?p3 WHERE { fma:Right_adrenal_gland ?p1 ?intermediary_1. ?intermediary_1 ?p2 ?intermediary_2. ?intermediary_2 ?p3 fma:Right_kidney. }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.