Difference between revisions of "DLQueryTab"

From Protege Wiki
Jump to: navigation, search
m
Line 18: Line 18:
 
* Once you've validated that your ontology is classified, you can execute a query.
 
* Once you've validated that your ontology is classified, you can execute a query.
  
== Simple query example ==
+
== Simple query examples ==
  
 
Suppose we have an ontology like this:
 
Suppose we have an ontology like this:
Line 41: Line 41:
  
 
We could also show all instances of person by simply providing the class in the query like this:
 
We could also show all instances of person by simply providing the class in the query like this:
 +
 +
[[Image:DLQueryIndividualsOfAClass.gif]]
 +
 +
Of course, these are extremely simple queries; the Manchester syntax is much more capable.
 +
 +
Literal constants can be expressed with type by using ^^ and then the type:
 +
 +
'''hasAge value "21"^^long'''
 +
 +
Or, a more general expression that uses type:
 +
 +
'''hasAge some int'''
 +
 +
Following are just a few more examples to get you going:
 +
 +
'''hasChild some Man'''
 +
 +
'''hasSibling only Woman'''
 +
 +
'''hasCountryOfOrigin value England'''
 +
 +
'''hasChild min 3'''
 +
 +
'''hasChild exactly 3'''
 +
 +
'''hasChild max 3'''
 +
 +
== Manchester OWL syntax ==
 +
 +
We have only provided a few simple examples here designed to help you understand how to use the DL Query tab and the Query view widget. To learn more about the Manchester syntax, check out these resources:
 +
 +
* [[http://www.co-ode.org/resources/reference/manchester_syntax/|The Manchester Syntax]] - describes the syntax for class expressions and is aimed at people who already know the previous Protege-OWL compact class expression syntax.
 +
* [[media:Owled2008dc_paper_11.pdf‎|Manchester Syntax for OWL 1.1]] - a more detailed whitepaper (PDF) including revisions for OWL 1.1.

Revision as of 19:48, March 25, 2008

DL Query tab

Protege4DLQueryTab.gif

The DL Query tab provides a powerful and easy-to-use feature for searching a classified ontology. It is a standard Protégé 4 plugin, available both as a tab and also as a view widget that can be positioned into any other tab. The query language (class expression) supported by the plugin is based on the Manchester OWL syntax, a user-friendly syntax for OWL DL that is fundamentally based on collecting all information about a particular class, property, or individual into a single construct, called a frame.


Getting started

If the DL Query tab is unavailable in your Protégé workspace, make sure the DL Query item in the Tabs menu is checked. Alternatively, you can add the Query view widget to any other tab by selecting View > Misc views > Query and then placing the widget anywhere in a layout.

You can only execute a query on a classified ontology. Before attempting to execute a query, run a classifier:

  • Ensure that one of the built-in reasoners (a.k.a classifiers) is selected. From the Reasoner menu, select FaCT++ or Pellet. When you first select a reasoner, the active ontology will be classified. You can also select Reasoner > Classify... to classify again at any time.
  • Validate that your ontology is classified by selecting the Entities tab and then the Inferred Class Hierarchy tab that appears in the class hierarchy view. It should contain classes that sub-class Thing. If you see only the root class, Thing, your ontology may not be classified. Following is an example comparing what an Inferred Class Hierarchy looks like before and after classification.

UnclassifiedVsClassifiedOntology.gif

  • Once you've validated that your ontology is classified, you can execute a query.

Simple query examples

Suppose we have an ontology like this:

  • Class:
    • Person
  • Data Properties:
    • hasGivenName
    • hasSurname

And suppose also that we have several hundred instances of class Person in our ontology. To find an individual name "Matthew", we could enter the following query:

hasGivenName value "Matthew"

But clicking on the execute button will may not return any results. We also need to check the "Individuals" option. Any individuals found will then be displayed in the query results as shown below:

DLQueryResults.gif

The following query would also be valid for the same result:

Person and hasGivenName value "Matthew"

We could also show all instances of person by simply providing the class in the query like this:

DLQueryIndividualsOfAClass.gif

Of course, these are extremely simple queries; the Manchester syntax is much more capable.

Literal constants can be expressed with type by using ^^ and then the type:

hasAge value "21"^^long

Or, a more general expression that uses type:

hasAge some int

Following are just a few more examples to get you going:

hasChild some Man

hasSibling only Woman

hasCountryOfOrigin value England

hasChild min 3

hasChild exactly 3

hasChild max 3

Manchester OWL syntax

We have only provided a few simple examples here designed to help you understand how to use the DL Query tab and the Query view widget. To learn more about the Manchester syntax, check out these resources:

  • [Manchester Syntax] - describes the syntax for class expressions and is aimed at people who already know the previous Protege-OWL compact class expression syntax.
  • Manchester Syntax for OWL 1.1 - a more detailed whitepaper (PDF) including revisions for OWL 1.1.