• No results found

3.3 Ontology Development with Prot´eg´e ODE

3.3.5 Reasoning and Queries

3.3.5.1 Description Logic (DL) Queries

DL Query is a simple and powerful ontology searching mechanism used to search for class expressions in a consistent ontology. The Ontology needs to be clas- sified (by invoking a Reasoner) before running a DL Query over it. DL queries are written using an easy to use syntax called ’Manchester OWL Syntax’ which is a user-friendly, human readable syntax that allows writing class or individual expressions as queries and the results will be displayed in the ’Query Result’ tab. Unlike the XML/RDF and OWL/XML syntaxes for OWL 2, it is a frame-based format where complete information about a Class, Individual, or property is col- lected in a single assembly called frame.

An example DL query in Manchester syntax to retrieve ”a class with at least one feature” and :another class with exactly a ’leaf’ as its feature”, from our Crop Ontology in DL will be thus:

• hasFeatures some Features

• hasFeatures value ’Leaf’

Figure 3.3: DL Query tab showing Reasoner not Initialized error

As shown in the figure 3.3, a reasoner need to be initialized and inference achieved before a DL query can be written. This is to ensure that the ontol- ogy is consistent before answering, which helps to avoid incomplete information retrieval. See section 3.3.5.3 for details on ontology inference and consistency checking.

3.3.5.2 SPARQL Queries — for Large and Federated Queries

As earlier explained, the building block of Semantic Web data is the Resource Description Framework (RDF) triple graph, and SPARQL is the query language for manipulating the RDF graph data. SPARQL is a recursive acronym which stands for: ’SPARQL Protocol and RDF Query Language’. SPARQL queries can contain a combination of RDF triples with disjunctions and/or conjunctions of classes and properties. The subject, object, and predicate triples in SPARQL queries contain variables which will be used to match existing graph patterns in the Ontology knowledge base.

SPARQL Query Format: In its basic form, the SPARQL contains a ’SELECT’ and ’WHERE’ clauses, just as in SQL Queries, see the Listing below:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#>

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?subject ?object

WHERE {?subject rdfs:subClassOf ?object }

ORDER BY GROUP BY ...

Note that the PREFIXes are imports for the RDF syntax namespaces (rdf-syntax- ns), OWL syntax (owl), XML Schema (XMLSchema) and RDF Schema (rdf- schema) respectively. They are standard prefixes needed to access, retrieve and presents the ontology data correctly. Other prefixes are added below these stan- dard prefixes to show the path to any participating ontology or data source for the SELECT statement. Hence, various data sources can be searched at once through the federated SPARQL query feature. We highlight the resulting case study of the SPARQL searching in our Onto-CropBase tool in Chapter 4.

3.3.5.3 Consistency Checking

As earlier discussed, developing ontologies requires a Reasoner to be invoked to ensure consistency and infer additional knowledge from asserted axioms. Com-

monly used reasoners available in the Prot´eg´e ODE includes the Pellet, HermiT, Fact++, and Pellet Incremental [14]. To check for the consistency of ontologies, the Reasoner tab provided in the Prot´eg´e menu provides the list of default rea- soners and their reasoning strategy. For more explicit reasoning, the ’Reasoner Configuration’ sub tab is selected to configure what pre-computation tasks needs to be done. For a simple ontology development, it is recommended that the default setting be allowed, were the Reasoner plug-ins decides the pre-computation task such as ’Initialization, Classification, and Realization’.

Figure 3.4: Reasoner Inferences Selection in Prot´eg´e ODE

In the preferences display, users can chose from check-boxes (See Fig. 3.4) which inferences will be realized and displayed in the ODE. Selectively un-checking some of the boxes to disable the automatic inference of unnecessary inferences, such as disjoint classes, super-properties, etc, will go a long way in improving the Reasoner performance and speed. Moreover, as shown in Fig. 3.3, an active reasoner is also needed to allow writing SWRL rules and for DL query execution. As such, it is strongly advisable that the reasoner is always active during ontology development to avoid introducing intractable inconsistencies.

3.3.5.4 Adding Query Results to Ontologies

Due to the complex and eliciting nature of queries, an ’Add to Ontology’ option is provided during DL query (See Fig. 3.3) writing to enable the assertion of the ex- act query results into the ontology — as a new class. This helps to avoid repeated query writing and allow for efficient knowledge extraction from ontologies.

Figure 3.5: Reflexive Ontology Generation - Adding Query Results in Prot´eg´e ODE

This reflexive ontology generation approach, though rarely mentioned, is highly efficient in enhancing the knowledge elicitation process in domain ontologies. However, as shown in Fig. 3.5, a new class need to be created which can lead to further alignment of the main ontology. For easier utilization of this feature, a separate class ”QueryResults” can be created as a sibling class to the ’Domain- Concept’ class to collate all new queries. This will help to avoid inconsistencies and ease of management of the main ontology.