Difference between revisions of "DLQueryTab"

From Protege Wiki
Jump to: navigation, search
m
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
__TOC__
 +
 +
'''Back to [[Protege4UserDocs|Protege User Documentation]]'''
 +
 
= DL Query tab =
 
= DL Query tab =
  
[[Image:Protege4DLQueryTab.gif|left|thumbnail]]
+
[[Image:Protege4DLQueryTab.gif|left|thumb]]
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.
+
The DL Query tab provides a powerful and easy-to-use feature for searching a classified ontology. It comes with the standard distribution of Protégé Desktop (versions 4, 5 and above), 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.
 +
 
  
 +
<br style="clear: both;" />
  
 
== Getting started ==
 
== 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.
+
[[Image:UnclassifiedVsClassifiedOntology.gif|right]]
 +
 
 +
If the DL Query tab is unavailable in your Protégé workspace, make sure the DL Query item in the '''Window | Tabs''' menu is checked. Alternatively, you can add the Query view widget to any other tab by selecting '''Window | Views | Query views''' 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:
 
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.  
+
* Ensure that one of the built-in reasoners (a.k.a classifiers) is selected. From the Reasoner menu, select FaCT++ or HermiT, then select '''Reasoner | Start Reasoner''' to classify the active ontology. You can also select '''Reasoner | Synchronize reasoner''' (or type Ctrl+R on Windows or Cmd+R on the Mac) 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.
+
* Validate that your ontology is classified by selecting the Entities tab and then the "Class hierarchy (inferred)" 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.
  
[[Image:UnclassifiedVsClassifiedOntology.gif]]
+
* 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.
+
<br style="clear: both;" />
 +
 
 +
== Individual query examples ==
  
== Simple query example ==
+
[[Image:DLQueryResults.gif|right]]
 +
[[Image:DLQueryIndividualsOfAClass.gif|right]]
  
 
Suppose we have an ontology like this:
 
Suppose we have an ontology like this:
Line 28: Line 39:
 
** hasSurname
 
** 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:
+
And suppose also that we have several hundred instances of class Person in our ontology. To find an individual named "Matthew", we could enter the following query:
  
 
'''hasGivenName value "Matthew"'''
 
'''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:
+
But clicking on the execute button 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:
 
 
[[Image:DLQueryResults.gif]]
 
  
 
The following query would also be valid for the same result:
 
The following query would also be valid for the same result:
Line 41: Line 50:
  
 
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:
 +
 +
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'''
 +
 +
<br style="clear: both;" />
 +
 +
== Class query examples ==
 +
 +
Here are some examples of class queries that can be performed on the [http://130.88.198.11/co-ode-files/ontologies/photography.owl ontology of photography] (work in progress).
 +
 +
Firstly, it can be useful to see which things classify "under" this expression.
 +
 +
'''Q: "Which equipment can reduce blur?"'''
 +
 +
We need to get the subclasses of the expression (or descendants if the hierarchy of equipment is deeper than 1 level):
 +
  Equipment and reduces some Blur
 +
 +
 +
[[Image:Dl-query-equip-blur2.png]]
 +
 +
 +
Then, we might be interested to see under which existing classes in our hierarchy a given class will classify:
 +
 +
'''Q: "What types of lens is a 35-120mm?"'''
 +
 +
We need to get the superclasses of the expression:
 +
  Lens and (hasMinEffectiveFocalLength value 35) and (hasMaxEffectiveFocalLength value 120)
 +
 +
 +
[[Image:Dl-query-lens2.png]]
 +
 +
 +
Other examples might be:
 +
 +
'''Q: "Which adjustments can I use to increase the exposure without affecting the depth of field"'''
 +
 +
We need to get the subclasses of the expression:
 +
  Adjustment and increases some ExposureLevel and not(affects some DepthOfField)
 +
 +
 +
[[Image:Dl_query_increase_exposure.png]]
 +
 +
 +
<br style="clear: both;" />
 +
 +
== Saving a query in the ontology ==
 +
 +
The DL Query tab becomes a useful way of testing a definition before creating appropriate classes.
 +
 +
If you find a particular query useful and would like to create a class to represent it, you can select the '''Add to ontology''' button.
 +
 +
Protege will display a "Create a new OWLClass" dialog where you enter a class name.  Clicking the OK button will then create a defined class in your ontology.
 +
 +
<br style="clear: both;" />
 +
 +
== 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 view widgets. To learn more about the Manchester Syntax, check out this resources:
 +
 +
* [https://www.w3.org/TR/owl2-manchester-syntax/ The Manchester Syntax] - describes the syntax for class expressions.
 +
 +
 +
 +
'''Back to [[Protege4UserDocs|Protege User Documentation]]'''

Latest revision as of 20:15, May 23, 2016

Back to Protege User Documentation

DL Query tab

Protege4DLQueryTab.gif

The DL Query tab provides a powerful and easy-to-use feature for searching a classified ontology. It comes with the standard distribution of Protégé Desktop (versions 4, 5 and above), 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

UnclassifiedVsClassifiedOntology.gif

If the DL Query tab is unavailable in your Protégé workspace, make sure the DL Query item in the Window | Tabs menu is checked. Alternatively, you can add the Query view widget to any other tab by selecting Window | Views | Query views 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 HermiT, then select Reasoner | Start Reasoner to classify the active ontology. You can also select Reasoner | Synchronize reasoner (or type Ctrl+R on Windows or Cmd+R on the Mac) to classify again at any time.
  • Validate that your ontology is classified by selecting the Entities tab and then the "Class hierarchy (inferred)" 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.
  • Once you've validated that your ontology is classified, you can execute a query.


Individual query examples

DLQueryResults.gif
DLQueryIndividualsOfAClass.gif

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 named "Matthew", we could enter the following query:

hasGivenName value "Matthew"

But clicking on the execute button 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:

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:

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


Class query examples

Here are some examples of class queries that can be performed on the ontology of photography (work in progress).

Firstly, it can be useful to see which things classify "under" this expression.

Q: "Which equipment can reduce blur?"

We need to get the subclasses of the expression (or descendants if the hierarchy of equipment is deeper than 1 level):

 Equipment and reduces some Blur


Dl-query-equip-blur2.png


Then, we might be interested to see under which existing classes in our hierarchy a given class will classify:

Q: "What types of lens is a 35-120mm?"

We need to get the superclasses of the expression:

 Lens and (hasMinEffectiveFocalLength value 35) and (hasMaxEffectiveFocalLength value 120)


Dl-query-lens2.png


Other examples might be:

Q: "Which adjustments can I use to increase the exposure without affecting the depth of field"

We need to get the subclasses of the expression:

 Adjustment and increases some ExposureLevel and not(affects some DepthOfField)


Dl query increase exposure.png



Saving a query in the ontology

The DL Query tab becomes a useful way of testing a definition before creating appropriate classes.

If you find a particular query useful and would like to create a class to represent it, you can select the Add to ontology button.

Protege will display a "Create a new OWLClass" dialog where you enter a class name. Clicking the OK button will then create a defined class in your ontology.


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 view widgets. To learn more about the Manchester Syntax, check out this resources:


Back to Protege User Documentation