Package org.semanticweb.owl.model

Examples of org.semanticweb.owl.model.OWLOntology


      return false;
    }
  }
 
  public boolean computeMetrics(URI uri, String ontName) throws OWLReasonerException{
    OWLOntology ontology = loadOntology(uri);
    if (ontology != null){
      rowCnt++;
      int colCnt = -1;
     
      VocabularyManager vManager = new VocabularyManager(ontology);
      Set<OWLClass> concepts = vManager.getConceptSet();
      Set<OWLProperty<?,?>> properties = vManager.getPropertySet();
     
      Set<OWLIndividual> allIndividuals = ontology.getReferencedIndividuals();
   
      String link = "<a href=\"viewmetrics.php?o="+ontName+"\">C</a>&nbsp;<a href=\"viewmetrics-i.php?o="+ontName+"\">I</a>";
      this.writeToFile(this.output, ontName + " ");
      String htmlRow = "<tr>\n\t<td bgcolor=\"#FFFFFF\" align=\"left\"><a href=\"viewmetrics.php?o="+ontName+"\">"+ontName+"</a></td>\n";
      String dataCell = "data.setCell("+rowCnt+", "+(++colCnt)+", '"+ontName+"&nbsp"+link+"');\n";
     
      this.logger.info("Ontology " + ontology.getURI() + " loaded");
     
      this.logger.info("\tClasses: " + concepts.size());
      this.writeToFile(this.output, concepts.size() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+concepts.size()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+concepts.size()+", '"+concepts.size()+"');\n";
     
      this.logger.info("\tProperties: " + properties.size());
      this.writeToFile(this.output, properties.size() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+properties.size()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+properties.size()+", '"+properties.size()+"');\n";
     
      this.logger.info("\tIndividual count: " + allIndividuals.size());
      this.writeToFile(this.output, allIndividuals.size() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+allIndividuals.size()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+allIndividuals.size()+", '"+allIndividuals.size()+"');\n";     
     
      this.logger.info("\tAxioms: " + ontology.getAxioms().size());
      this.writeToFile(this.output, ontology.getAxioms().size() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+ontology.getAxioms().size()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+ontology.getAxioms().size()+", '"+ontology.getAxioms().size()+"');\n";
     
      this.logger.info("\tSubClass Axioms: " + ontology.getAxiomCount(AxiomType.SUBCLASS));
      this.writeToFile(this.output, ontology.getAxiomCount(AxiomType.SUBCLASS) + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+ontology.getAxiomCount(AxiomType.SUBCLASS)+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+ontology.getAxiomCount(AxiomType.SUBCLASS)+", '"+ontology.getAxiomCount(AxiomType.SUBCLASS)+"');\n";
     
      this.logger.info("\tLogical Axioms: " + ontology.getLogicalAxiomCount());
      this.writeToFile(this.output, ontology.getLogicalAxiomCount() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+ontology.getLogicalAxiomCount()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+ontology.getLogicalAxiomCount()+", '"+ontology.getLogicalAxiomCount()+"');\n";
     
      this.logger.info("\tAnnotation Axioms: " + ontology.getAnnotationAxioms().size());
      this.writeToFile(this.output, ontology.getAnnotationAxioms().size() + " ");
     
      this.logger.info("\tClass Axioms: " + ontology.getClassAxioms().size());
      this.writeToFile(this.output, ontology.getClassAxioms().size() + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+ontology.getClassAxioms().size()+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+ontology.getClassAxioms().size()+", '"+ontology.getClassAxioms().size()+"');\n";
     
      OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(ontology));
      ExistentialAxiomVisitor<OWLObject> myVisitor = new ExistentialAxiomVisitor<OWLObject>();
     
      walker.walkStructure(myVisitor);
     
      this.logger.info("\tsubClass = " + myVisitor.subClassCnt);
      this.logger.info("\tclassAssertAxiom = " + myVisitor.classAssertAxiomCnt);
      this.logger.info("\tentityAnnAxiom = " + myVisitor.entityAnnAxiomCnt);
     
      this.logger.info("\tdataSomeRestriction = " + myVisitor.dataSomeRestrictionCnt);
      this.logger.info("\tobjectSomeRestriction = " + myVisitor.objectSomeRestrictionCnt);
      int someCnt = myVisitor.dataSomeRestrictionCnt + myVisitor.objectSomeRestrictionCnt;
      this.writeToFile(this.output, someCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+someCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+someCnt+", '"+someCnt+"');\n";
     
      this.logger.info("\tdataAllRestriction = " + myVisitor.dataAllRestrictionCnt);
      this.logger.info("\tobjectAllRestriction = " + myVisitor.objectAllRestrictionCnt);
      int allCnt = myVisitor.dataAllRestrictionCnt + myVisitor.objectAllRestrictionCnt;
      this.writeToFile(this.output, allCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+allCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+allCnt+", '"+allCnt+"');\n";
     
      this.logger.info("\tobjectIntersectionOf = " + myVisitor.objectIntersectionOfCnt);
      this.writeToFile(this.output, myVisitor.objectIntersectionOfCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.objectIntersectionOfCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.objectIntersectionOfCnt+", '"+myVisitor.objectIntersectionOfCnt+"');\n";
     
      this.logger.info("\tobjectUnionOf = " + myVisitor.objectUnionOfCnt);
      this.writeToFile(this.output, myVisitor.objectUnionOfCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.objectUnionOfCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.objectUnionOfCnt+", '"+myVisitor.objectUnionOfCnt+"');\n";
     
      this.logger.info("\tobjectComplementOf = " + myVisitor.objectComplementOfCnt);
      this.writeToFile(this.output, myVisitor.objectComplementOfCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.objectComplementOfCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.objectComplementOfCnt+", '"+myVisitor.objectComplementOfCnt+"');\n";
     
      this.logger.info("\tEquivalent Class Axioms = " + myVisitor.equivClassesCnt);
      this.writeToFile(this.output, myVisitor.equivClassesCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.equivClassesCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.equivClassesCnt+", '"+myVisitor.equivClassesCnt+"');\n";
     
      this.logger.info("\tDisjoint Class Axioms = " + myVisitor.disjClassesCnt);
      this.writeToFile(this.output, myVisitor.disjClassesCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.disjClassesCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.disjClassesCnt+", '"+myVisitor.disjClassesCnt+"');\n";
     
      this.logger.info("\tSame Individual Axioms = " + myVisitor.sameIndividualAxiomCnt);
      this.writeToFile(this.output, myVisitor.sameIndividualAxiomCnt + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+myVisitor.sameIndividualAxiomCnt+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+myVisitor.sameIndividualAxiomCnt+", '"+myVisitor.sameIndividualAxiomCnt+"');\n";
     
      //int value = ontology.getAxiomCount(AxiomType.OBJECT_PROPERTY_ASSERTION);
      int value = ontology.getObjectPropertyAxioms().size();
      this.logger.info("\tObject Property Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.OBJECT_PROPERTY_DOMAIN);
      this.logger.info("\tObject Property Domain Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";

      value = ontology.getAxiomCount(AxiomType.OBJECT_PROPERTY_RANGE);
      this.logger.info("\tObject Property Range Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.SUB_OBJECT_PROPERTY);
      this.logger.info("\tSub Object Property Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.TRANSITIVE_OBJECT_PROPERTY);
      this.logger.info("\tTransitive Object Property Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.DATA_PROPERTY_ASSERTION);
      this.logger.info("\tData Property Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.DATA_PROPERTY_DOMAIN);
      this.logger.info("\tData Property Domain Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";

      value = ontology.getAxiomCount(AxiomType.DATA_PROPERTY_RANGE);
      this.logger.info("\tData Property Range Axioms: " + value);
      this.writeToFile(this.output, value + " ");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
      value = ontology.getAxiomCount(AxiomType.SUB_DATA_PROPERTY);
      this.logger.info("\tSub Data Property Axioms: " + value);
      this.writeToFile(this.output, value + "\n");
      htmlRow += "\t<td bgcolor=\"#FFFFFF\" align=\"right\">"+value+"</td>\n</tr>\n";
      dataCell += "data.setCell("+rowCnt+", "+(++colCnt)+", "+value+", '"+value+"');\n";
     
View Full Code Here


      return false;
    }
  }
 
  private OWLOntology loadOntology(URI uri){
    OWLOntology ontology = null;
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    try{
      ontology = manager.loadOntologyFromPhysicalURI(uri);
      return ontology;
    }catch (OWLOntologyCreationException e) {
View Full Code Here

 
  public static void main(String[] args) {
    URI ontologyURI = null;
    URI tboxURI = null;
    URI aboxURI = null;
    OWLOntology ontology = null;
   
    if (args.length != 2){
      System.out.println("Usage: main <ontologylist.txt> <split method ([1|2])>");
      System.out.println("Usage: split method 1: based on OWLIndividualAxiom (desired)");
      System.out.println("Usage: split method 2: based on OWLClassAssertionAxiom");
View Full Code Here

    try{
      OWLOntologyManager tboxMgr = OWLManager.createOWLOntologyManager();
      OWLOntologyManager aboxMgr = OWLManager.createOWLOntologyManager();
     
      // Create two ontologies: Tbox and Abox
      OWLOntology tbox = tboxMgr.createOntology(tboxURI);
      OWLOntology abox = aboxMgr.createOntology(aboxURI);
   
      Set<OWLLogicalAxiom> axioms = ontology.getLogicalAxioms();
      logger.info("Number of logical axioms: "+axioms.size());
      for (OWLLogicalAxiom axiom : axioms){
        if (axiom instanceof OWLIndividualAxiom){
View Full Code Here

    try{
      OWLOntologyManager tboxMgr = OWLManager.createOWLOntologyManager();
      OWLOntologyManager aboxMgr = OWLManager.createOWLOntologyManager();
     
      // Create two ontologies: Tbox and Abox
      OWLOntology tbox = tboxMgr.createOntology(tboxURI);
      OWLOntology abox = aboxMgr.createOntology(aboxURI);
   
      Set<OWLLogicalAxiom> axioms = ontology.getLogicalAxioms();
      logger.info("Number of logical axioms: "+axioms.size());
      for (OWLLogicalAxiom axiom : axioms){
        if (axiom instanceof OWLClassAssertionAxiom){
View Full Code Here

    }
  }

  private static boolean populate(URI uri, int instances, URI outputFile){
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = loadOntology(manager, uri);
    if (ontology != null){
      try {
        OWLDataFactory factory = manager.getOWLDataFactory();
        VocabularyManager vManager = new VocabularyManager(ontology);
        List<OWLClass> classes = new Vector<OWLClass>(vManager.getConceptSet());
       
        List<OWLAxiomChange> toAdd = new Vector<OWLAxiomChange>();
        for (int i = 0; i < instances; i++) {
          int rnd = m_random.nextInt(classes.size());
          OWLClassAssertionAxiom newAxiom = factory.getOWLClassAssertionAxiom(newIndividual(factory), classes.get(rnd));
          toAdd.add(new AddAxiom(ontology,newAxiom))
          System.out.println((i+1)+"- new axiom: "+newAxiom.toString());
        }       
        manager.applyChanges(toAdd);
        OutputStreamWriter sw = new FileWriter(new File(outputFile));
        OWLOntologyOutputTarget target = new WriterOutputTarget(sw);
        manager.saveOntology(ontology, target);
        return true;
      } catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        return false;
      } catch (IOException e) {
        e.printStackTrace();
        return false;
      } catch (OWLOntologyStorageException e) {
        e.printStackTrace();
        return false;
      } finally{
        manager.removeOntology(ontology.getURI());
        manager = null;
      }
    }
    return false;
  }
View Full Code Here

  private static OWLIndividual newIndividual(OWLDataFactory factory) {
    return factory.getOWLIndividual(URI.create("http://www.example.com/instance#i" + Math.abs(m_random.nextInt())));
  }
 
  private static OWLOntology loadOntology(OWLOntologyManager manager, URI uri){
    OWLOntology ontology = null;
    try{
      ontology = manager.loadOntologyFromPhysicalURI(uri);
      return ontology;
    }catch (OWLOntologyCreationException e) {
      e.printStackTrace();
View Full Code Here

   
    Logger logger = Logger.getLogger(Processor.class.getName());
   
    logger.info("Ontology: " + tBoxPhysicalURI.toString());
   
    OWLOntology tboxOntology;
    try
    {
      // load the ontology using the ontology manager
      // we need only classes (concepts) from it
      tboxOntology = manager.loadOntologyFromPhysicalURI(tBoxPhysicalURI);
View Full Code Here

    /* Stores the set of instances of every class */
    HashMap<OWLClass, Set<OWLIndividual>> complete = new HashMap<OWLClass, Set<OWLIndividual>>();

    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

    OWLOntology tbox = null;
    OWLOntology abox = null;
    try
    {
      tbox = manager.loadOntologyFromPhysicalURI(tboxPhysicalURI);
      abox = manager.loadOntologyFromPhysicalURI(aboxPhysicalURI);

      VocabularyManager vManager = new VocabularyManager(tbox);
      Set<OWLClass> classes = vManager.getConceptSet();
     
      Set<OWLProperty<?, ?>> properties = new HashSet<OWLProperty<?, ?>>();

      logger.info("Selected vocabulary subset: ");
      int cCounter = 1;
      for (OWLClass owlClass : classes)
      {
        logger.info("Concept " + cCounter + ": " + owlClass.getURI());
        cCounter++;
      }
      logger.info("Selected property subset: ");
      int pCounter = 1;
      for (OWLProperty<?, ?> owlProperty : properties)
      {
        logger.info("Property " + pCounter + ": "
            + owlProperty.getURI());
        pCounter++;
      }
      logger.info("");

      org.mindswap.pellet.utils.Timers timers = new Timers();
     
      timers.createTimer("classification");

      /* Create the reaosner */
      OWLReasoner reasoner = reasonerFactory.createReasoner(manager);

      System.out
          .println("Classifying and retrieving instance relations...");
      this.logger
          .info("Classifying and retrieving instance relations...");
      this.logger.info("Using reasoner: "
          + reasonerFactory.getReasonerName());

      /* Load Tbox into reasoner */
      reasoner.loadOntologies(Collections.singleton(tbox));

      /* Load Abox into reasoner */
      // reasoner.loadOntologies(Collections.singleton(abox));
      /* Classify the ontology if necessary */
      if (!reasoner.isClassified())
      {
        /* Measure time using Benchmarking framework */
        Timer timerClassify = timers.startTimer("classification");
        reasoner.classify();
        timerClassify.stop();
        classificationTime = timerClassify.getTotal();
      }

      /* Load Abox into reasoner */
      reasoner.loadOntologies(Collections.singleton(abox));
      if (!reasoner.isClassified())
      {
        reasoner.classify();
      }

      /*
       * Maps each class to the number of instances (including direct and
       * indirect)
       */
      HashMap<OWLClass, Integer> allIndividualsCounts = new HashMap<OWLClass, Integer>();

      /* Maps each class to the number of direct instances */
      HashMap<OWLClass, Integer> directIndividualsCounts = new HashMap<OWLClass, Integer>();

      /* Maps each class to the number of indirect instances */
      HashMap<OWLClass, Integer> indirectIndividualsCounts = new HashMap<OWLClass, Integer>();

      int individualCounter = 1;

      for (OWLClass cc : classes)
      {
        allIndividuals = new HashSet<OWLIndividual>();
        directIndividuals = new HashSet<OWLIndividual>();

        if (reasoner.isDefined(cc))
        {
          /*
           * retrieve all individuals of the class (direct and
           * indirect individuals)
           */
          timers.createTimer("retrieval");
          Timer timerRetrieval = timers.startTimer("retrieval");
          allIndividuals = reasoner.getIndividuals(cc, false);
          timerRetrieval.stop();

          /* update instance retrieval time */
          instanceRetrievalTime += timerRetrieval.getTotal();

          /* retrieve all direct instances of the class */
          directIndividuals = reasoner.getIndividuals(cc, true);
        } else
        {
          logger.info("Undefined Concept in Tbox: " + cc);
        }

        /* set the number of instances (direct + indirect) of the class */
        allIndividualsCounts
            .put(cc, new Integer(allIndividuals.size()));

        /* set the number of direct instances of the class */
        directIndividualsCounts.put(cc, new Integer(directIndividuals
            .size()));

        /* set the number of indirect instances of the class */
        indirectIndividualsCounts.put(cc, new Integer(allIndividuals
            .size()
            - directIndividuals.size()));

        complete.put(cc, allIndividuals);
        cumulativeNumberOfInstances += allIndividuals.size();
        cumulativeNumberOfDirectInstances += directIndividuals.size();
        cumulativeNumberOfIndirectInstances += (allIndividuals.size() - directIndividuals
            .size());

        /* Log the indirect instances found */
        HashSet<OWLIndividual> difference = new HashSet<OWLIndividual>(
            allIndividuals);
        difference.removeAll(directIndividuals);
        if (difference.size() > 0)
        {
          logger.info("");
          logger.info("Indirect instance relations found for class "
              + cc.getURI() + ": " + difference.size());
          for (OWLIndividual owli : difference)
          {
            logger.info(individualCounter + ": " + owli.getURI());
            individualCounter++;
          }
        }
      }

      time = (classificationTime + instanceRetrievalTime) - loadingTime;
      RunResult result = new RunResult(allIndividualsCounts, time,
          classes.size(), properties.size());
      result.setClassificationTime(classificationTime);
      result.setOntologyLoadingTime(loadingTime);
      result.setDirectIndividuals(directIndividualsCounts);
      result.setIndirectIndividuals(indirectIndividualsCounts);
      result.setInstanceRetrievalTime(instanceRetrievalTime);
      result.setInstances(complete);
      result.setRunNumber(approximationCnt);
      result.setRunType(runType);

      this.logger.info("");
      this.logger.info("#Instance relations: "
          + cumulativeNumberOfInstances);
      this.logger.info("#Direct instances relations retrieved: "
          + cumulativeNumberOfDirectInstances);
      this.logger.info("#Indirect instances relations retrieved: "
          + cumulativeNumberOfIndirectInstances);
      this.logger.info("Runtime (ms): " + time);
      this.logger.info("Classification Time (ms): " + classificationTime);
      this.logger
          .info("Reasoner creation and ontology loading time (ms): "
              + loadingTime);
      this.logger
          .info("Instance Retrieval Time (ms) (approx.: total time - classification time): "
              + instanceRetrievalTime);
      this.logger.info("Tbox URI: " + tboxPhysicalURI);
      this.logger.info("Abox URI: " + aboxPhysicalURI);
      this.logger
          .info("============================================================================================================");

      reasoner.clearOntologies();
     
      reasoner.dispose();
      manager.removeOntology(abox.getURI());
      manager.removeOntology(tbox.getURI());
      reasoner = null;

      return result;

View Full Code Here

      }
    }
    try
    {
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
      OWLOntology tboxOntology = null, aboxOntology = null;
      try
      {
        // load the Tbox and Abox
        tboxOntology = manager.loadOntology(tboxPhysicalURI);
        aboxOntology = manager
            .loadOntologyFromPhysicalURI(aboxPhysicalURI);
      } catch (OWLOntologyCreationException e)
      {
        e.printStackTrace();
        System.exit(0);
      }

      StepSizeStrategy stepSizeStrategy = StrategyFactory
          .newStepSizeStrategy("EqualParts", maxPoint.size());

      String methodString = "Random";
      if (method == 1)
      {
        methodString = "Google";
      }
      File file = new File(resultsDirectory + ontology + "_"
          + methodString + "_" + round2Decimals(maxGainScore)
          + ".csv");
      DataOutputStream dos = new DataOutputStream(new FileOutputStream(
          file));

      // dos.writeBytes("Gain Score, " + maxGainScore + "\n");
      dos
          .writeBytes("Concept, Google Score, No Descendats, No Ancestors, No Definig Axioms, No Referencing Axioms, Classes in Signature, No Superclasses, No Subclasses, No Disjoint Classes, No Equivalent Clases, No Direct Individuals, Bin No\n");

      int s = stepSizeStrategy.getNextStepSize();
      int bin = 1;
      int i = 0;
      for (OWLClass c : maxPoint)
      {
        dos.writeBytes(c.getURI().toString() + ", ");
        dos.writeBytes(((Integer) googleScores.get(c.getURI()
            .toString())).toString()
            + ", ");
        dos.writeBytes(getNoDescendants(c, tboxOntology) + ", ");
        dos.writeBytes(getNoAncestors(c, tboxOntology) + ", ");
        dos.writeBytes(tboxOntology.getAxioms(c).size() + ", ");
        dos.writeBytes(tboxOntology.getReferencingAxioms(c).size()
            + ", ");
        dos.writeBytes(c.getClassesInSignature().size() + ", ");
        dos.writeBytes(c.getSuperClasses(tboxOntology).size() + ", ");
        dos.writeBytes(c.getSubClasses(tboxOntology).size() + ", ");
        dos
View Full Code Here

TOP

Related Classes of org.semanticweb.owl.model.OWLOntology

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.