01
02 package examples;
03
04 import com.hp.hpl.jena.ontology.Individual;
05 import com.hp.hpl.jena.ontology.OntProperty;
06 import com.hp.hpl.jena.rdf.model.RDFNode;
07 import dlejena.DLEJenaReasoner;
08 import java.io.File;
09 import java.net.URI;
10
11 /**
12 * A simple example that demonstrates the semantics of property chains
13 *
14 * @author Georgios Meditskos <gmeditsk@csd.auth.gr>
15 */
16 public class PropertyChain {
17
18 public static void main(String[] args) {
19
20 /*
21 * The physical URI (local path or Web address) of the ontology.
22 */
23 URI ontology = new File("src/examples/propertyChain.owl").toURI();
24
25 /*
26 * Define an instance of the DLEJenaReasoner class.
27 * This class provides the necessary nethods for
28 * using the DLEJena library
29 */
30 DLEJenaReasoner dle = new DLEJenaReasoner();
31
32 /*
33 * Register the ontology to the reasoner.
34 */
35 dle.register(ontology);
36
37 /*
38 * Initiate the reasoner. This phase involves the
39 * separation of the TBox from ABox axioms (using the OWLAPI),
40 * the TBox reasoning procedure (using Pellet), the generation of the
41 * dynamic entailments and the ABox reasoning procedure (using
42 * the forwardRete rule engine of Jena).
43 */
44 dle.initialize();
45
46 /**
47 * Print the ABox entailment rules. Note the entailment that handles
48 * the property chain isPartOf o isLocatedIn -> iPartOf:
49 * [ D_prp-spo2: (?u1 http://propertyChain.owl#isPartOf ?u2) (?u2 http://propertyChain.owl#isLocatedIn ?u3) -> (?u1 http://propertyChain.owl#isPartOf ?u3) ]
50 */
51 System.out.println("ABox entailment rules:");
52 dlejena.utils.Print.printRuleSet(dle.getABoxRules());
53
54 /* The asserted ABox knowledge contains that
55 * <a1 isPartOf a2>,
56 * <a2 isLocatedIn a3>.
57 *
58 * Print the inferred information that finally <a1 isPartOf a3>
59 */
60 System.out.println("");
61 Individual a1 = dle.getABox().getIndividual("http://propertyChain.owl#a1");
62 OntProperty isPartOf = dle.getTBox().getOntProperty("http://propertyChain.owl#isPartOf");
63 Individual v = (Individual) a1.getPropertyValue(isPartOf).as(Individual.class);
64 System.out.println(a1.getLocalName() + " " + isPartOf.getLocalName() + " " + v.getLocalName());
65 }
66 }
|