Package com.clarkparsia.pellet.owlapiv3

Examples of com.clarkparsia.pellet.owlapiv3.OWLClassTreePrinter


          .create( premiseURI ) );
      manager = org.semanticweb.owlapi.apibinding.OWLManager.createOWLOntologyManager();
      org.semanticweb.owlapi.model.OWLOntology conclusion = manager.loadOntology( IRI
          .create( conclusionURI ) );

      PelletReasoner reasoner = new com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory()
          .createReasoner( premise );
      assertTrue( reasoner.isEntailed( conclusion.getAxioms() ) );
    } catch( org.semanticweb.owlapi.model.OWLOntologyCreationException e ) {
      throw new RuntimeException( e );
    }

  }
View Full Code Here


  public void testClassification(String inputOnt) throws IOException {
    File testFile = new File( TEST_FILE );
    OWLOntology ontology = OntologyUtils.loadOntology( inputOnt );
   
    try {
      PelletReasoner unified = PelletReasonerFactory.getInstance().createReasoner( ontology );
      ModuleExtractor moduleExtractor = createModuleExtractor();

      IncrementalClassifier modular = new IncrementalClassifier( unified, moduleExtractor );

      modular.classify();

      FileOutputStream fos = new FileOutputStream( testFile );

      IncrementalClassifierPersistence.save( modular, fos );

      fos.close();

      FileInputStream fis = new FileInputStream( testFile );
     
      IncrementalClassifier modular2 = IncrementalClassifierPersistence.load( fis );

      fis.close();

      assertClassificationEquals( unified, modular2 );

      assertTrue( testFile.delete() );
     
      unified.dispose();
      modular.dispose();
      modular2.dispose();
    }
    finally {
      OWL.manager.removeOntology( ontology );
View Full Code Here

        OWL.manager.applyChange( new RemoveAxiom( modular.getRootOntology(), axiomToRemove) );
      }

      modular.classify();

      PelletReasoner expected = PelletReasonerFactory.getInstance().createReasoner( modular.getRootOntology() );   

      assertClassificationEquals( expected, modular );
    } finally {
      OWL.manager.removeOntology( ontology );
    }
View Full Code Here

        OWL.manager.applyChange( new RemoveAxiom(ontology, axiomToRemove ) );
      }

      modular.classify();

      PelletReasoner expected = PelletReasonerFactory.getInstance().createReasoner( ontology );

      assertClassificationEquals( expected, modular );
    } finally {
      OWL.manager.removeOntology( ontology );
    }
View Full Code Here

      modular = IncrementalClassifierPersistence.load( fis, ontology );

      fis.close();

      PelletReasoner expected = PelletReasonerFactory.getInstance().createReasoner( ontology );

      assertClassificationEquals( expected, modular );
    } finally {
      OWL.manager.removeOntology( ontology );
    }
View Full Code Here

  public void testClassification(String inputOnt, String classifiedOnt) throws OWLOntologyCreationException {
    OWLOntology premise = OWL.manager.loadOntology( IRI.create( inputOnt ) );
    OWLOntology conclusion = OWL.manager.loadOntology( IRI.create( classifiedOnt ) );
   
    try {
      PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( premise );
      reasoner.getKB().classify();
 
      List<OWLAxiom> nonEntailments = new ArrayList<OWLAxiom>();
         
      for( OWLSubClassOfAxiom axiom : conclusion.getAxioms( AxiomType.SUBCLASS_OF ) ) {
        boolean entailed = reasoner.getSubClasses( axiom.getSuperClass(), true ).containsEntity( (OWLClass) axiom.getSubClass() );
       
        if( !entailed ) {
          if( AbstractClassificationTest.FAIL_AT_FIRST_ERROR )
            fail( "Not entailed: " + axiom );
          else
            nonEntailments.add( axiom );
        }
      }
 
      for( OWLEquivalentClassesAxiom axiom : conclusion
          .getAxioms( AxiomType.EQUIVALENT_CLASSES ) ) {
        boolean entailed = reasoner.isEntailed( axiom );
       
        if( !entailed ) {
          if( AbstractClassificationTest.FAIL_AT_FIRST_ERROR )
            fail( "Not entailed: " + axiom );
          else
            nonEntailments.add( axiom );
        }
      }
     
      for( OWLClassAssertionAxiom axiom : conclusion.getAxioms( AxiomType.CLASS_ASSERTION ) ) {
        boolean entailed = reasoner.getInstances( axiom.getClassExpression(), true ).containsEntity( (OWLNamedIndividual) axiom.getIndividual() );
       
        if( !entailed ) {
          if( AbstractClassificationTest.FAIL_AT_FIRST_ERROR )
            fail( "Not entailed: " + axiom );
          else
View Full Code Here

  public void testRealization(String inputOnt) throws IOException {
    File testFile = new File( TEST_FILE );
    OWLOntology ontology = OntologyUtils.loadOntology( inputOnt );
   
    try {
      PelletReasoner unified = PelletReasonerFactory.getInstance().createReasoner( ontology );
      ModuleExtractor moduleExtractor = createModuleExtractor();

      IncrementalClassifier modular = new IncrementalClassifier( unified, moduleExtractor );
      modular.classify();

      // first we only persist classified-but-not-realized classifier
      assertFalse( modular.isRealized() );

      FileOutputStream fos = new FileOutputStream( testFile );

      IncrementalClassifierPersistence.save( modular, fos );

      fos.close();

      FileInputStream fis = new FileInputStream( testFile );

      IncrementalClassifier modular2 = IncrementalClassifierPersistence.load( fis );

      fis.close();
      assertTrue( testFile.delete() );

      // the classifier read from file should NOT be realized at this point
      assertFalse( modular.isRealized() );
     
      assertInstancesEquals( unified, modular2 );
      assertTypesEquals( unified, modular2 );
     
      // the previous tests should have triggered realization
      assertTrue( modular2.isRealized() );

      // save the classifier again and read it back
      fos = new FileOutputStream( testFile );

      IncrementalClassifierPersistence.save( modular2, fos );

      fos.close();

      fis = new FileInputStream( testFile );

      IncrementalClassifier modular3 = IncrementalClassifierPersistence.load( fis );

      fis.close();
      assertTrue( testFile.delete() );

      // the classifier read from file should be realized at this point
      assertTrue( modular3.isRealized() );
     
      assertInstancesEquals( unified, modular3 );
      assertTypesEquals( unified, modular3 );
     
      unified.dispose();
      modular.dispose();
      modular2.dispose();
      modular3.dispose();
    }
    finally {
View Full Code Here

    try {
      ProgressMonitor monitor = new TimedProgressMonitor( 1 );
 
      OWLOntology ont = loadOntology( base + "food.owl" );
     
      PelletReasoner pellet = PelletReasonerFactory.getInstance().createReasoner( ont );
      KnowledgeBase kb = pellet.getKB();
 
      kb.classify();
 
      kb.getTaxonomyBuilder().setProgressMonitor( monitor );
 
View Full Code Here

  public void testClassificationTimeout() throws Exception {
    boolean timeout = false;

    OWLOntology ont = loadOntology( base + "food.owl" );

    PelletReasoner pellet = PelletReasonerFactory.getInstance().createReasoner( ont );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "classify" );
    timer.setTimeout( 1 );

View Full Code Here

  public void testRealizationTimeout() throws Exception {
    boolean timeout = false;

    OWLOntology ont = loadOntology( "file:" + PelletTestSuite.base + "modularity/SWEET.owl" );

    PelletReasoner pellet = PelletReasonerFactory.getInstance().createReasoner( ont );
    KnowledgeBase kb = pellet.getKB();

    Timer timer = kb.timers.createTimer( "realize" );
    timer.setTimeout( 1 );

    try {
View Full Code Here

TOP

Related Classes of com.clarkparsia.pellet.owlapiv3.OWLClassTreePrinter

Copyright © 2018 www.massapicom. 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.