Example #1
0
  private void writeResultsToFile() throws Exception {
    PropertyFileHandler propertyFileHandler = PropertyFileHandler.getInstance();
    HostInfo resultNodeHostInfo = propertyFileHandler.getResultNode();
    // port: 6489 for snapshot testing
    Jedis resultStore =
        new Jedis(
            resultNodeHostInfo.getHost(), resultNodeHostInfo.getPort(), Constants.INFINITE_TIMEOUT);
    new ResultRearranger().initializeAndRearrange();
    // rearranged results are in DB-1
    resultStore.select(1);
    Set<String> resultKeys = resultStore.smembers(Constants.RESULT_KEYS);
    PrintWriter writer =
        new PrintWriter(new BufferedWriter(new FileWriter("final-saxioms-distel.txt")));
    System.out.println("Writing results to final-saxioms-distel.txt");

    for (String key : resultKeys) {
      Set<String> superClasses = resultStore.smembers(key);
      for (String sc : superClasses) writer.println(key + "|" + sc);
    }
    writer.close();
    resultStore.close();
  }
Example #2
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();
    }
  }