Pellet 101

From Tetherless World Wiki

Jump to: navigation, search


Contents

Pellet DL Reasoner

facts

  • OWL DL reasoner
  • Pellet is distributed under the terms of the MIT license.
  • Pellet was started at the Mindswap Lab directed by Dr. James Hendler and funded by various organizations. As of the 1.4 release, Pellet development shifted to Clark & Parsia, which offers commercial support and customization for Pellet.

How to install

  1. goto http://pellet.owldl.com/, and download latest version

Pellet Reasoning

supported OWL ontology constructs

  • full expressivity of OWL-DL
  • additional OWL 1.1 features
  • inverse functional datatype properties
  • vocabulary sharing between individuals, classes, and properties
  • built-in datatype and user defined datatype support

use Pellet reasoner

   ... from ExplanationExample.java
   
   //declare manager and factory
   OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
   OWLDataFactory factory = manager.getOWLDataFactory();
   
   // read the ontology
   OWLOntology ontology = manager.loadOntology( URI.create( file ) );
   
   // create some concepts
   OWLClass mad_cow = factory.getOWLClass( URI.create( ns + "mad+cow" ) );
   OWLClass animal_lover = factory.getOWLClass( URI.create( ns + "animal+lover" ) );
   OWLClass pet_owner = factory.getOWLClass( URI.create( ns + "pet+owner" ) );
   
   // create a converter to turn ATerm's into OWLAPI axioms
   AxiomConverter converter = new AxiomConverter( ontology, factory );
   
   // IMPORTANT: The option to enable tracing should be turned on before
   // the ontology is loaded to the reasoner!
   PelletOptions.USE_TRACING = true;
   
   // create the reasoner and load the ontology
   Reasoner pellet = new Reasoner( manager );
   pellet.loadOntology( ontology );
   
   // check for concept satisfiability
   pellet.isSatisfiable( mad_cow );
   
   // convert the latest explanation to OWLAPI
   Set<OWLAxiom> exp1 = convertExplanation( converter, pellet.getKB().getExplanationSet() );
   
   // print the explanation
   printAxioms( "Why is mad+cow concept unsatisfiable:", exp1 );

DL inference services

  • Ontology Consistency checking - Ensures that an ontology does not contain any contradictory facts.
   ((PelletInfGraph) model.getGraph()).getKB().isConsistent();
  • Concept satisfiability - Determines whether it’s possible for a class to have any instances. unsatisfiable concept will cause the entire ontology inconsistent.
   // check for concept satisfiability
   pellet.isSatisfiable( mad_cow );
  • pinpointing axioms that cause an inconsistency, c.f. Debugging OWL Ontologies , PDF
   // IMPORTANT: make sure explanation is turned on, this options can be
   // turned on and off arbitrarily during the program but should be turned on
   pellet.getKB().setDoExplanation( true );
   
   // convert the latest explanation to OWLAPI
   Set<OWLAxiom> exp1 = convertExplanation( converter, pellet.getKB().getExplanationSet() );
  • Classification - Computes the subclass relations between every named class to create the complete class hierarchy.
   ...from ClassTree.java
   ((PelletInfGraph) model.getGraph()).getKB().classify();
  • Realization - Finds the most specific classes that an individual belongs to; i.e., realization computes the direct types for each of the individuals.
   ((PelletInfGraph) model.getGraph()).getKB().realize();

support SPARQL (excluding DESCRIBE)

  • RDF data are loaded into Pellet reasoner, and OWL DL inference will be done before executing SPARQL query
   ... check PelletQueryExample.java
   Query query = QueryFactory.create(queryStr);
   if (!query.isSelectType()) {
       throw new UnsupportedFeatureException("Only SELECT supported for this example");
   }
   // create an empty ontology model using Pellet spec
   OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );    
   model.setStrictMode( false );
      
   if( query.getGraphURIs().size() == 0 )
       throw new UnsupportedFeatureException(
            "SPARQL query must have a FROM clause for this example");
   
   for (Iterator iter = query.getGraphURIs().iterator(); iter.hasNext();) {
       String sourceURI = (String) iter.next();
       model.read( sourceURI );
   }
       
   QueryExecution qexec = new PelletQueryExecution(query, model);
   ResultSet results = qexec.execSelect();

Pellet Interface and demos

  • Implementation of reasoner interfaces Jena and Manchester OWL-API library
   ... from JenaReasoner.java
   // create Pellet reasoner
   Reasoner reasoner = PelletReasonerFactory.theInstance().create();
   
   // create an empty model
   Model emptyModel = ModelFactory.createDefaultModel( );
   
   // create an inferencing model using Pellet reasoner
   InfModel model = ModelFactory.createInfModel( reasoner, emptyModel );
   
   // read the file
   model.read( ont );
   
   // print validation report
   ValidityReport report = model.validate();
   printIterator( report.getReports(), "Validation Results" );
   
   // print superclasses
   Resource c = model.getResource( ont + "MaleStudentWith3Daughters" );     
   printIterator(model.listObjectsOfProperty(c, RDFS.subClassOf), 
                 "All super classes of " + c.getLocalName());
   ... from OWLAPIExample.java
   OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
   OWLOntology ontology = manager.loadOntology(URI.create(file));
   
   Reasoner reasoner = new Reasoner( manager );
   System.out.println("done.");
   
   reasoner.loadOntology(ontology);
   
   reasoner.getKB().realize();
   reasoner.getKB().printClassTree();
   
   // create property and resources to query the reasoner
   OWLClass Person = manager.getOWLDataFactory().getOWLClass(
         URI.create("http://xmlns.com/foaf/0.1/Person"));
   OWLObjectProperty workHomepage = manager.getOWLDataFactory().getOWLObjectProperty(
         URI.create("http://xmlns.com/foaf/0.1/workInfoHomepage"));
   OWLDataProperty foafName = manager.getOWLDataFactory().getOWLDataProperty(
          URI.create("http://xmlns.com/foaf/0.1/name"));
   
   // get all instances of Person class
   Set individuals = reasoner.getIndividuals(Person, false);
   for(Iterator i = individuals.iterator(); i.hasNext(); ) {
   OWLIndividual ind = (OWLIndividual) i.next();
  • demos
    • An Web-based demonstration page OWLSight
    • A command line program with (included in the distribution package)
    • Direct integration with the ontology editor SWOOP

Exercises

TODO

Personal tools