Early Adopters Workshop, Hands-on session - DIG Reasoner Scenario
Contents
Under developement...
Description of the plug-in
A DIG interface plugin can call any external DL (Description Logic) reasoner which supports the DIG interface to reason with ontologies. Almost all of the existing DL reasoners, like Racer, KAON2, FACT++, Pellet, provide the DIG interface support.
A prototype implementation of such a DIG interface has been created in the larkc_plugins project in package src/eu.larkc.plugin.reason.dig. This reasoner can translate SPARQL queries into DIG queries and post them to an external DIG reasoner, then translate the answers from the external DIG reasoner into the answers of SPARQL.
One of the use cases of the DIG interface plug-in is to use it with an external PION, a system for reasoning with inconsistent ontologies, to get meaningful answers.
Purpose
The purpose of this scenario is to:
- provide an introduction to LarKC dig plug-in from a software developer's perspective
- show some typical examples of SPARQL queries to call an external DIG reasoner.
- provide a scenario how the external PION can be called for reasoning with inconsistent ontologies.
Step-by-Step
Setting up LarKC with a DIG reasoner
This tutorial requires to check out (i) the LarKC platform itself (https://svn.gforge.hlrs.de/svn/larkc/trunk/platform/) and (ii) the wrapped up DIG reasoner plugin (https://svn.gforge.hlrs.de/svn/larkc/trunk/plugins/).
The LarKC DIG plug-in requires an external DIG reasoner, like Racer, FACT++, KOAN2, Pellet. Before starting the test, make sure the external DIG reasoner has been installed at your computer(i.e., localhost) and is running at a known port.
Execution
The java program DIGReasonerTest.java at the dig plug-in source code directory provides several typical examples how an external DIG reasoner can be called to reasoning with ontologies at the LarKC platform.
Before executing the test program, you can change the following setting in the program:
String hostname= "localhost";
int port = 8080; String path = "/";The ontology data can be claimed by a code, like this:
String ontologyFileName = "http://www.cs.vu.nl/~huang/larkc/ontology/wine.rdf";
or
String ontologyFileName = "file:////E: /larkc/ontology/wine.rdf";
if the ontology data is located at the local harddisk.
The DIG reasoner plugin loads a set of OWLDL/DIG ontology along with a set of SPARLDL queries.
A typical example SPARQDL query which asks if a concept is a subconcept of another one is like this:
// to ask whether or not wine is a potable liquid
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
PREFIX food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
ASK
WHERE { wine:Wine rdfs:subClassOf food:PotableLiquid.}The query be stated as a string in a java code like this:
String query32 ="PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"+
"PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>\n" +
"PREFIX food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#>\n" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "ASK\n"+ "WHERE {"+
"wine:Wine rdfs:subClassOf food:PotableLiquid."+
"}";//+Using the following code to post the query to the external DIG reasoner and get the answer in the test java program:
ReasonerTest(ontologyFileName, query32, hostname, port, path);
A typical example SPARQDL query which asks if a concept is a sub concept of the conjunction of two other ones is like this:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
PREFIX food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
ASK
WHERE {
wine:Bordeaux rdfs:subClassOf _:x.
_:x owl:interSectionOf _:y1.
_:y1 rdf:first wine:SweetWine.
_:y1 rdf:rest wine:TableWine.
wine:Bordeaux rdf:type owl:Class.}which uses the OWL method to translate DL concept expressions (say, a conjunction of two concepts in the example above) into a triple set in a SPARQL query.
The following is an example of the sparql select query which ask for a list of subclass of Wine:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wine: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
SELECT ?X
WHERE { ?X rdfs:subClassOf wine:Wine.}
Use Case: Reasoning with Inconsistent Ontologies
In order to test reasoning with inconsistent ontologies, you have to install the external PION system (version 2.1.0 or higher) with SWI-Prolog on your computer. The PION system can be downloaded from the PION website: http://wasp.cs.vu.nl/sekt/pion. The SWI-Prolog can be downloaded from the SWI Prolog website: http://www.swi-prolog.org.
In order to test reasoning with inconsistent ontologies by PION, you can do the followings:
- Launch an external DL reasoner (like Racer) at the port 8000 of the localhost;
- Launch the external PION at the port 8001 of the localhost;
- Change the setting of the external DIG server by changing the following line at the test program: int port = 8001;// default port for PION
- Launch the test program with the LarKC platform.
Note that the current version of PION supports boolean queries only. Thus, what you can post to the external PION via the LarKC DIG plug-in should be an sparql ask query. Although you may get an answer from the external PION for a non-ask query(say a sparql select query), actually the answer is from the external DIG reasoner called by PION.
Here is an example of the query to test the external PION with an inconsistent ontology madcow3.dig.xml:
REFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ex: <http://wasp.cs.vu.nl/larkc/ontology/ex#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
ASK
WHERE { ex:themadcow rdf:type ex:vegetarian.}
You can see that PION can return a meaningful answer 'false'. You can compare that answer from PION with an answer from a standard DL-reasoner, say Racer. You can see that when querying an inconsistent ontology, the standard DL reasoner always returns an error message, like this:
<responses xmlns="http://dl.kr.org/dig/2003/02/lang"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dl.kr.org/dig/2003/02/lang
http://dl-web.man.ac.uk/dig/2003/02/dig.xsd">
<error id="http://wasp.cs.vu.nl/larkc/ontology/ex#themadcow http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://wasp.cs.vu.nl/larkc/ontolog/ex#vegetarian"
message="ABox http://dl.kr.org/dig/kb-1048 is incoherent."/>
</responses>
You can use the PION testbed page piontest2.htm to change the setting of the external PION for options of various selection functions (syntactic relevance, concept syntactic relevance, or semantic relevance by google distances), over-determed processing methods (first maximal consistent set, or path pruning with Google distances), and extension strategies (linear extension or k-extension). The functionality for changing the setting of PION via the LarKC DIG plug-in will be supported by the future release of the DIG plug-in.
