Examples of PelletReasoner


Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory factory = manager.getOWLDataFactory();
    OWLOntology ontology = manager.loadOntology( IRI.create( mindswappers ) );

    // we want a non-buffering reasoner here (a buffering reasoner would not process any additions, until manually refreshed)
    PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createNonBufferingReasoner( ontology );
    manager.addOntologyChangeListener( reasoner );

    // perform initial consistency check
    long s = System.currentTimeMillis();
    boolean consistent = reasoner.isConsistent();
    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in a consistent KB
    OWLClass concept = factory.getOWLClass( IRI.create( mindswap + "GraduateStudent" ) );
    OWLNamedIndividual individual = factory
        .getOWLNamedIndividual( IRI.create( mindswappers + "JohnDoe" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLClassAssertionAxiom( concept, individual ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = reasoner.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in an inconsistent KB
    OWLObjectProperty role = factory.getOWLObjectProperty( IRI.create( foaf + "mbox" ) );
    individual = factory.getOWLNamedIndividual( IRI.create( mindswappers + "Christian.Halaschek" ) );
    OWLNamedIndividual mbox = factory.getOWLNamedIndividual( IRI.create( "mailto:kolovski@cs.umd.edu" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLObjectPropertyAssertionAxiom(
        role, individual, mbox ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = reasoner.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );
  }
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

   
    System.out.print("Reading file " + file + "...");
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntology(IRI.create(file));

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ontology );
    System.out.println("done.");
   
    reasoner.getKB().realize();
    reasoner.getKB().printClassTree();
   
    // create property and resources to query the reasoner
    OWLClass Person = manager.getOWLDataFactory().getOWLClass(IRI.create("http://xmlns.com/foaf/0.1/Person"));
    OWLObjectProperty workHomepage = manager.getOWLDataFactory().getOWLObjectProperty(IRI.create("http://xmlns.com/foaf/0.1/workInfoHomepage"));
    OWLDataProperty foafName = manager.getOWLDataFactory().getOWLDataProperty(IRI.create("http://xmlns.com/foaf/0.1/name"));
   
    // get all instances of Person class
    NodeSet<OWLNamedIndividual> individuals = reasoner.getInstances( Person, false);
    for(Node<OWLNamedIndividual> sameInd : individuals) {
      // sameInd contains information about the individual (and all other individuals that were inferred to be the same)
      OWLNamedIndividual ind =  sameInd.getRepresentativeElement();
     
        // get the info about this specific individual
      Set<OWLLiteral> names = reasoner.getDataPropertyValues( ind, foafName );                       
        NodeSet<OWLClass> types = reasoner.getTypes( ind, true );       
        NodeSet<OWLNamedIndividual> homepages = reasoner.getObjectPropertyValues( ind, workHomepage );
       
        // we know there is a single name for each person so we can get that value directly
        String name = names.iterator().next().getLiteral();
      System.out.println( "Name: " + name );
       
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

   
    // read the ontology
    OWLOntology ontology = manager.loadOntology( IRI.create(ont) );
   
    // load the ontology to the reasoner
    PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createReasoner( ontology );
   
    // create property and resources to query the reasoner
    OWLClass Person = factory.getOWLClass(IRI.create("http://xmlns.com/foaf/0.1/Person"));
    OWLObjectProperty workHomepage = factory.getOWLObjectProperty(IRI.create("http://xmlns.com/foaf/0.1/workInfoHomepage"));
    OWLDataProperty foafName = factory.getOWLDataProperty(IRI.create("http://xmlns.com/foaf/0.1/name"));
   
    // get all instances of Person class
    Set<OWLNamedIndividual> individuals = reasoner.getInstances( Person, false ).getFlattened();
    for(OWLNamedIndividual ind : individuals) {     
        // get the info about this specific individual
      Set<OWLLiteral> names = reasoner.getDataPropertyValues( ind, foafName );                       
        NodeSet<OWLClass> types = reasoner.getTypes( ind, true );       
        NodeSet<OWLNamedIndividual> homepages = reasoner.getObjectPropertyValues( ind, workHomepage );
       
        // we know there is a single name for each person so we can get that value directly
        String name = names.iterator().next().getLiteral();
      System.out.println( "Name: " + name );
       
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    // create OWLEntities
    OWLOntologyManager manager = OWL.manager;
    OWLOntology ontology = manager.loadOntology( IRI.create( file ) );

    // Create the reasoner and load the ontology
    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ontology );

    // Create an explanation generator
    PelletExplanation expGen = new PelletExplanation( reasoner );

    // Create some concepts
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    for(OWLAxiom axiom: axiomsFromABox)
    {
      OWL.manager.applyChange( new AddAxiom( ontologyTBox, axiom ) );
    }
   
    PelletReasoner reasoner = com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory.getInstance().createReasoner( ontologyTBox );
   
    System.out.println("Entities:");
    for(int i=0; i< entities.length; i++)
    {
      OWLClass obj = (OWLClass) entities[i];
      String name = obj.toStringID();
      System.out.println("Class:  " + name.substring(name.indexOf("#")+1));
     
      // get all instances of Person class
      Set<OWLNamedIndividual> individuals = reasoner.getInstances( obj, false ).getFlattened();
      for(OWLNamedIndividual ind : individuals) {
        System.out.println("Individual: " + ind.toString());
      }
      System.out.println("---------------------------");
    }
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    factory = PelletReasonerFactory.getInstance();
  }
 
  public OWLReasoner getReasoner(OWLOntology ontology){
    OWLReasonerConfiguration config = new SimpleConfiguration(ReasonerPara.TIMEOUT);
    PelletReasoner reasoner = factory.createReasoner(ontology, config);
    return reasoner;
  }
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    return iri;
  }

  @Override
  protected boolean isConsistent(OWLOntology o) {
    PelletReasoner reasoner = reasonerFactory.createReasoner( o );
    reasoner.getKB().setTimeout( timeout );
    return reasoner.isConsistent();
  }
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    return reasoner.isConsistent();
  }

  @Override
  protected boolean isEntailed(OWLOntology premise, OWLOntology conclusion) {
    PelletReasoner reasoner = reasonerFactory.createReasoner( premise );
    reasoner.getKB().setTimeout( timeout );
    return reasoner.isEntailed( conclusion.getLogicalAxioms() );
  }
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

   
    return new Pair<OWLClass, OWLClass>( sub, sup );
  }
 
  private Set<OWLAxiom> getCachedExplanation(OWLClassExpression unsatClass) {
    PelletReasoner pellet = getReasoner();

    if( !pellet.getKB().isClassified() )
      return null;

    Pair<OWLClass,OWLClass> pair = getSubClassAxiom( unsatClass );

    if( pair != null ) {
      Set<Set<ATermAppl>> exps = TaxonomyUtils.getSuperExplanations(
          pellet.getKB().getTaxonomy(),
          pellet.term( pair.first ),
          pellet.term( pair.second ) );

      if( exps != null ) {
        Set<OWLAxiom> result = convertExplanation( exps.iterator().next() );
        if( log.isLoggable( Level.FINE ) )
          log.fine( "Cached explanation: " + result );
View Full Code Here

Examples of com.clarkparsia.pellet.owlapiv3.PelletReasoner

    return result;
  }

  private Set<OWLAxiom> getPelletExplanation(OWLClassExpression unsatClass) {
    PelletReasoner pellet = getReasoner();
   
    pellet.getKB().prepare();
   
    // satisfiable if there is an undefined entity
    boolean sat = !getDefinitionTracker().isDefined( unsatClass );
       
    if( !sat ) {
      sat = isSatisfiable( pellet, unsatClass, true );
    }
    else if( log.isLoggable( Level.FINE ) )
      log.fine( "Undefined entity in " + unsatClass );
     

    if( sat ) {
      return Collections.emptySet();
    }
    else {
      Set<OWLAxiom> explanation = convertExplanation( pellet.getKB().getExplanationSet() );

      if( log.isLoggable( Level.FINE ) )
        log.fine( "Explanation " + explanation );

      Set<OWLAxiom> prunedExplanation = pruneExplanation( unsatClass, explanation, true );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.