Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Terp: Syntax for
OWL-friendly SPARQL queries
  Evren Sirin, Blazej Bulka and Michael Smith
              Clark & Parsia, L...
Who are we?
• Clark & Parsia is a semantic software startup
  o   HQ in Washington, DC & office in Boston
• Provides softw...
Motivation
• Make it easy to read and write queries for
  OWL ontologies

• Allow both schema and instance queries
• Witho...
Querying OWL
• The most commonly used Semantic Web
  query language is SPARQL
• SPARQL intended for RDF
• Semantics based ...
Simple SPARQL Query
• Query: Find the flavors of red French wines
  PREFIX rdf: <http://...>
  PREFIX wine: <http://...>

 ...
SPARQL Abbreviations
• Query: Find the flavors of red French wines
 PREFIX wine: <http://...>

 SELECT ?wine ?flavor {
    ...
SPARQL Abbreviations
• Query: Find the flavors of red French wines
 PREFIX wine: <http://...>

 SELECT ?wine ?flavor {
    ...
SPARQL Abbreviations
• Query: Find the flavors of red French wines
 PREFIX wine: <http://...>       Object lists
          ...
SPARQL Abbreviations
• Query: Find the flavors of red French wines
 PREFIX wine: <http://...>       Object lists
          ...
SPARQL Abbreviations
• Query: Find the flavors of red French wines
 PREFIX wine: <http://...>       Object lists
          ...
OWL over RDF
• RDF knows about triples (and only triples)
• OWL has many different constructs
  •   Class/property/data ex...
SPARQL over OWL
• Query: Find wines that are made of at least
  two grapes
  SELECT ?wine ?flavor {
     ?wine a [ owl:int...
SPARQL over OWL
• Query: Find wines that are made of at least
  two grapes
  SELECT ?wine ?flavor {
     ?wine a [ owl:int...
SPARQL over OWL
• Query: Find wines that are made of at least
  two grapes
  SELECT ?wine ?flavor {
      ?wine a [ owl:in...
SPARQL over OWL
• Query: Find wines that are made of at least
  two grapes
  SELECT ?wine ?flavor {
      ?wine a [ owl:in...
We have a syntax for that!
• Pick the OWL syntax suitable for you
We have a syntax for that!
• Pick the OWL syntax suitable for you
 •   I want a formal syntax: Use Functional Syntax
We have a syntax for that!
• Pick the OWL syntax suitable for you
 •   I want a formal syntax: Use Functional Syntax

 •  ...
We have a syntax for that!
• Pick the OWL syntax suitable for you
 •   I want a formal syntax: Use Functional Syntax

 •  ...
We have a syntax for that!
• Pick the OWL syntax suitable for you
 •   I want a formal syntax: Use Functional Syntax

 •  ...
We have a syntax for that!
• Pick the OWL syntax suitable for you
 •   I want a formal syntax: Use Functional Syntax

 •  ...
Terp Syntax
• Combine Turtle with Manchester syntax
• Use Manchester syntax for expressing class,
   property, or datatype...
Complex Terp Example
•   Query: Find meal courses that go with full-bodied
    wines, if exists return the associated labe...
Terp Grammar
• Merge SPARQL grammar with Manchester
  syntax grammar
• Keep all the syntax features of SPARQL
• A few case...
Implementation
• Terp parser implemented in Pellet and
  available as of version 2.1

• Integrated through Jena ARQ archit...
Possible Extensions
• Allow Manchester syntax in predicate position
  •   Ex: Use equivalentTo instead of owl:equivalentCl...
Questions?
Upcoming SlideShare
Loading in …5
×

Terp: An OWL-friendly SPARQL

Terp is a SPARQL syntax that makes querying OWL ontologies much easier.

  • Be the first to comment

Terp: An OWL-friendly SPARQL

  1. 1. Terp: Syntax for OWL-friendly SPARQL queries Evren Sirin, Blazej Bulka and Michael Smith Clark & Parsia, LLC
  2. 2. Who are we? • Clark & Parsia is a semantic software startup o HQ in Washington, DC & office in Boston • Provides software development and integration services • Specializing in Semantic Web, web services, and advanced AI technologies for federal and enterprise customers http://clarkparsia.com/ Twitter: @candp
  3. 3. Motivation • Make it easy to read and write queries for OWL ontologies • Allow both schema and instance queries • Without inventing a completely new query language • Not hard to learn
  4. 4. Querying OWL • The most commonly used Semantic Web query language is SPARQL • SPARQL intended for RDF • Semantics based on pattern matching over RDF graphs • Semantics extensions possible via entailment regimes • SPARQL-DL extension [OWLED 2008 paper] • SPARQL 1.1 entailment regime [SPARQL WG]
  5. 5. Simple SPARQL Query • Query: Find the flavors of red French wines PREFIX rdf: <http://...> PREFIX wine: <http://...> SELECT ?wine ?flavor { ?wine rdf:type wine:FrenchWine . ?wine rdf:type wine:RedWine . ?wine wine:hasFlavor ?flavor . }
  6. 6. SPARQL Abbreviations • Query: Find the flavors of red French wines PREFIX wine: <http://...> SELECT ?wine ?flavor { ?wine a wine:FrenchWine , wine:RedWine ; wine:hasFlavor ?flavor . }
  7. 7. SPARQL Abbreviations • Query: Find the flavors of red French wines PREFIX wine: <http://...> SELECT ?wine ?flavor { ?wine a wine:FrenchWine , wine:RedWine ; wine:hasFlavor ?flavor . } Turtle keyword a instead of rdf:type
  8. 8. SPARQL Abbreviations • Query: Find the flavors of red French wines PREFIX wine: <http://...> Object lists separated by comma SELECT ?wine ?flavor { ?wine a wine:FrenchWine , wine:RedWine ; wine:hasFlavor ?flavor . } Turtle keyword a instead of rdf:type
  9. 9. SPARQL Abbreviations • Query: Find the flavors of red French wines PREFIX wine: <http://...> Object lists separated by comma SELECT ?wine ?flavor { ?wine a wine:FrenchWine , wine:RedWine ; wine:hasFlavor ?flavor . } Turtle keyword a Predicate-object instead of rdf:type lists separated by semi-colon
  10. 10. SPARQL Abbreviations • Query: Find the flavors of red French wines PREFIX wine: <http://...> Object lists separated by comma SELECT ?wine ?flavor { ?wine a wine:FrenchWine , wine:RedWine ; wine:hasFlavor ?flavor . } Turtle keyword a Predicate-object instead of rdf:type lists separated by semi-colon • Result: a concise query
  11. 11. OWL over RDF • RDF knows about triples (and only triples) • OWL has many different constructs • Class/property/data expressions, axioms, etc. • Triple-based representation of OWL can be • verbose • unintuitive • hard to read or understand
  12. 12. SPARQL over OWL • Query: Find wines that are made of at least two grapes SELECT ?wine ?flavor { ?wine a [ owl:intersectionOf ( wine:Wine [ a owl:Restriction ; owl:onProperty wine:madeFromGrape ; owl:minCardinality 2 ])] }
  13. 13. SPARQL over OWL • Query: Find wines that are made of at least two grapes SELECT ?wine ?flavor { ?wine a [ owl:intersectionOf ( RDF List wine:Wine abbreviation [ a owl:Restriction ; owl:onProperty wine:madeFromGrape ; owl:minCardinality 2 ])] }
  14. 14. SPARQL over OWL • Query: Find wines that are made of at least two grapes SELECT ?wine ?flavor { ?wine a [ owl:intersectionOf ( RDF List wine:Wine abbreviation Bnode [ a owl:Restriction ; abbreviation owl:onProperty wine:madeFromGrape ; owl:minCardinality 2 ])] }
  15. 15. SPARQL over OWL • Query: Find wines that are made of at least two grapes SELECT ?wine ?flavor { ?wine a [ owl:intersectionOf ( RDF List wine:Wine abbreviation Bnode [ a owl:Restriction ; abbreviation owl:onProperty wine:madeFromGrape ; owl:minCardinality 2 ])] } • Result: less than ideal (no OWL shortcuts)
  16. 16. We have a syntax for that! • Pick the OWL syntax suitable for you
  17. 17. We have a syntax for that! • Pick the OWL syntax suitable for you • I want a formal syntax: Use Functional Syntax
  18. 18. We have a syntax for that! • Pick the OWL syntax suitable for you • I want a formal syntax: Use Functional Syntax • I want a syntax that plays nicely with XQuery and XML schema: Use OWL/XML syntax
  19. 19. We have a syntax for that! • Pick the OWL syntax suitable for you • I want a formal syntax: Use Functional Syntax • I want a syntax that plays nicely with XQuery and XML schema: Use OWL/XML syntax • I want to write OWL expressions easily: Use Manchester Syntax
  20. 20. We have a syntax for that! • Pick the OWL syntax suitable for you • I want a formal syntax: Use Functional Syntax • I want a syntax that plays nicely with XQuery and XML schema: Use OWL/XML syntax • I want to write OWL expressions easily: Use Manchester Syntax • I want a triple-friendly syntax: Use Turtle syntax
  21. 21. We have a syntax for that! • Pick the OWL syntax suitable for you • I want a formal syntax: Use Functional Syntax • I want a syntax that plays nicely with XQuery and XML schema: Use OWL/XML syntax • I want to write OWL expressions easily: Use Manchester Syntax • I want a triple-friendly syntax: Use Turtle syntax • I don’t need your help: Use RDF/XML syntax
  22. 22. Terp Syntax • Combine Turtle with Manchester syntax • Use Manchester syntax for expressing class, property, or datatype expressions • Manchester syntax expressions can appear in subject or object position of triples SELECT ?wine ?flavor { ?wine a ( wine:Wine and wine:madeFromGrape min 2 ) }
  23. 23. Complex Terp Example • Query: Find meal courses that go with full-bodied wines, if exists return the associated label; order results by labels but don’t include owl:Nothing. SELECT ?wine ?flavor { ?mealCourse rdfs:subClassOf food:MealCourse , food:hasDrink some ( wine:Wine and wine:hasBody value wine:Full ) OPTIONAL { ?mealCourse rdfs:label ?label } FILTER ( ?mealCourse != owl:Nothing ) } ORDER BY rdfs:label
  24. 24. Terp Grammar • Merge SPARQL grammar with Manchester syntax grammar • Keep all the syntax features of SPARQL • A few cases where ambiguity arises • Ex: Parentheses are used for lists in SPARQL and for nesting in Manchester syntax • Try to resolve ambiguity by the context • Assume SPARQL intent otherwise
  25. 25. Implementation • Terp parser implemented in Pellet and available as of version 2.1 • Integrated through Jena ARQ architecture • Can translate any Terp query to regular SPARQL syntax • Can be used programmatically or through CLI
  26. 26. Possible Extensions • Allow Manchester syntax in predicate position • Ex: Use equivalentTo instead of owl:equivalentClass and owl:equivalentProperty • Support for additional OWL 2 constructs • Ex: Negative property assertions, axiom annotations • More syntactic sugar for frequently used OWL features
  27. 27. Questions?

×