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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. We have a syntax for that!
• Pick the OWL syntax suitable for you
17. We have a syntax for that!
• Pick the OWL syntax suitable for you
• I want a formal syntax: Use Functional Syntax
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. 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. 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. 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. 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. 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. 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. 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. 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