@Override
 public void dispose() {
   if (reasoner != null) {
     reasoner.dispose();
     reasoner = null;
   }
 }
示例#2
0
 /** Release the reasoner */
 public void disposeReasoner() {
   synchronized (reasonerMutex) {
     if (reasoner != null) {
       reasoner.dispose();
       reasoner = null;
     }
   }
 }
示例#3
0
 private void classifyWithJFact(OWLOntology ontology) {
   System.out.println("\nUsing JFact ...");
   long startTime = System.nanoTime();
   OWLReasonerFactory reasonerFactory = new JFactFactory();
   OWLReasoner jfactReasoner = reasonerFactory.createReasoner(ontology);
   jfactReasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
   jfactReasoner.dispose();
   System.out.println("Time taken (secs): " + Util.getElapsedTimeSecs(startTime));
 }
示例#4
0
 private void classifyWithSnorocket(OWLOntology ontology) {
   System.out.println("\nUsing Snorocket...");
   long startTime = System.nanoTime();
   SnorocketReasonerFactory srf = new SnorocketReasonerFactory();
   OWLReasoner snorocketReasoner = srf.createReasoner(ontology);
   snorocketReasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
   snorocketReasoner.dispose();
   System.out.println("Time taken (secs): " + Util.getElapsedTimeSecs(startTime));
 }
示例#5
0
 /** Only call within a {@link #moduleReasonerMutex} synchronized block!! */
 private void _internalDisposeModuleReasonerAndListener() {
   if (moduleReasoner != null) {
     moduleReasoner.dispose();
     moduleReasoner = null;
   }
   if (moduleListener != null) {
     aboxOntology.getOWLOntologyManager().removeOntologyChangeListener(moduleListener);
     moduleListener = null;
   }
 }
示例#6
0
  public void getELKIncrementalRuntime(String baseOnt, String ontDir) throws Exception {
    GregorianCalendar start = new GregorianCalendar();
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    IRI documentIRI = IRI.create(new File(baseOnt));
    OWLOntology baseOntology = manager.loadOntology(documentIRI);
    System.out.println("Logical axioms: " + baseOntology.getLogicalAxiomCount());
    //		findDataHasValueAxiom(baseOntology.getAxioms(AxiomType.SUBCLASS_OF));

    OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
    OWLReasoner reasoner = reasonerFactory.createReasoner(baseOntology);
    reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
    File[] files = new File(ontDir).listFiles();
    int count = 0;
    OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();
    addTripsBaseOntologies(manager2);
    for (File file : files) {
      System.out.println("File name: " + file.getName());
      documentIRI = IRI.create(file);
      OWLOntology ontology = manager2.loadOntology(documentIRI);
      Set<OWLLogicalAxiom> axioms = ontology.getLogicalAxioms();
      //	    	findDataHasValueAxiom(ontology.getAxioms(AxiomType.SUBCLASS_OF));
      manager.addAxioms(baseOntology, axioms);
      reasoner.flush();
      System.out.println("Logical axioms: " + baseOntology.getLogicalAxiomCount());

      // From the ELK wiki, it seems ABox reasoning will trigger TBox reasoning
      reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS);

      manager2.removeOntology(ontology);
      count++;
      System.out.println("Done with " + count);
      //	    	if(count == 5)
      //	    		break;
    }
    reasoner.dispose();
    System.out.println("Time taken (millis): " + Util.getElapsedTime(start));
  }
示例#7
0
  private void precomputeAndCheckResults(OWLOntology ontology) throws Exception {
    System.out.println("Not Normalizing");

    PropertyFileHandler propertyFileHandler = PropertyFileHandler.getInstance();
    HostInfo resultNodeHostInfo = propertyFileHandler.getResultNode();
    // port: 6489 for snapshot testing
    Jedis resultStore =
        new Jedis(
            resultNodeHostInfo.getHost(), resultNodeHostInfo.getPort(), Constants.INFINITE_TIMEOUT);
    Jedis resultStore2 =
        new Jedis(
            resultNodeHostInfo.getHost(), resultNodeHostInfo.getPort(), Constants.INFINITE_TIMEOUT);
    resultStore2.select(2);
    HostInfo localHostInfo = propertyFileHandler.getLocalHostInfo();
    Jedis localStore = new Jedis(localHostInfo.getHost(), localHostInfo.getPort());
    Set<String> idHosts =
        localStore.zrange(
            AxiomDistributionType.CONCEPT_ID.toString(),
            Constants.RANGE_BEGIN,
            Constants.RANGE_END);
    // currently there is only one ID node
    String[] idHostPort = idHosts.iterator().next().split(":");
    Jedis idReader =
        new Jedis(idHostPort[0], Integer.parseInt(idHostPort[1]), Constants.INFINITE_TIMEOUT);
    GregorianCalendar cal1 = new GregorianCalendar();
    try {
      //		    OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
      //		    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
      //		    reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
      //		    PelletReasoner reasoner = PelletReasonerFactory.getInstance().
      //		    									createReasoner( ontology );
      //		    reasoner.prepareReasoner();

      //	    Reasoner hermitReasoner = new Reasoner(ontology);
      //	    hermitReasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

      //	    	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
      //		    OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
      //		    reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

      //		    RELReasonerFactory relfactory = new RELReasonerFactory();
      //		    RELReasoner reasoner = relfactory.createReasoner(ontology);
      //		    reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

      //	    	JcelReasoner reasoner = new JcelReasoner(ontology, false);
      //		    reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

      OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
      OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
      reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

      System.out.println("Reasoner completed in (millis): " + Util.getElapsedTime(cal1));

      System.out.println("Comparing results using ELK.....");
      rearrangeAndCompareResults(ontology, reasoner, resultStore, resultStore2, idReader);

      //		    pelletReasoner.dispose();
      //	   		reasonerELK.dispose();
      reasoner.dispose();
    } finally {
      localStore.disconnect();
      resultStore.disconnect();
      resultStore2.disconnect();
      idReader.disconnect();
    }
  }