コード例 #1
0
 public void writeOntologyHeader(OWLOntology ontology) {
   event = new RendererEvent(this, ontology);
   fireFrameRenderingPrepared(ONTOLOGY.toString());
   write(ONTOLOGY.toString());
   write(":");
   writeSpace();
   if (!ontology.isAnonymous()) {
     int indent = getIndent();
     writeFullURI(ontology.getOntologyID().getOntologyIRI().toString());
     writeNewLine();
     pushTab(indent);
     if (ontology.getOntologyID().getVersionIRI() != null) {
       writeFullURI(ontology.getOntologyID().getVersionIRI().toString());
     }
     popTab();
   }
   fireFrameRenderingStarted(ONTOLOGY.toString());
   writeNewLine();
   for (OWLImportsDeclaration decl : ontology.getImportsDeclarations()) {
     fireSectionItemPrepared(IMPORT.toString());
     write(IMPORT.toString());
     write(":");
     writeSpace();
     fireSectionRenderingStarted(IMPORT.toString());
     writeFullURI(decl.getURI().toString());
     writeNewLine();
     fireSectionRenderingFinished(IMPORT.toString());
   }
   writeNewLine();
   writeSection(ANNOTATIONS, ontology.getAnnotations(), ",", true);
   fireFrameRenderingFinished(ONTOLOGY.toString());
 }
 public void visit(OWLOntology ontology) {
   checkOccurrence(ontology.getAnnotations());
   for (AxiomType<?> t : AxiomType.AXIOM_TYPES) {
     for (OWLAxiom ax : ontology.getAxioms(t)) {
       checkOccurrence(ax.getAnnotations());
       ax.accept(this);
     }
   }
   singleAppearance.clear();
 }
コード例 #3
0
ファイル: OntologyManager.java プロジェクト: gesteban/sened
 private OntologyManager() {
   _manager = OWLManager.createOWLOntologyManager();
   try {
     _ontology = _manager.loadOntology(IRI.create(getClass().getResource(ONTOLOGY_RESOURCE_PATH)));
     for (OWLAnnotation anon : _ontology.getAnnotations()) {
       if (anon.getProperty().getIRI().toString().equals(DomainOntology.taxonomyDefinedBy)) {
         _taxonomyType = anon.getValue().toString().replace("\"", "");
         break;
       }
     }
     _reasoner = new StructuralReasonerFactory().createReasoner(_ontology);
   } catch (OWLOntologyCreationException ex) {
     Log.e(TAG, "Error while loading the domain ontology");
     _taxonomyType = null;
   }
 }
コード例 #4
0
ファイル: SynonymTest.java プロジェクト: khazelton/owlapi
  @Test
  public void testConvert() throws Exception {
    // PARSE TEST FILE
    OWLOntology ontology = convert(parseOBOFile("synonym_test.obo"));

    Set<OWLAnnotation> anns = ontology.getAnnotations();
    for (OWLAnnotation ann : anns) {
      // TODO
      System.out.println("Ann=" + ann);
    }

    Set<OWLAnnotationProperty> aps = ontology.getAnnotationPropertiesInSignature();
    for (OWLAnnotationProperty ap : aps) {
      System.out.println("ap=" + ap);
    }

    // TODO

  }
コード例 #5
0
  public void mergeOntologies() {
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
    for (OWLOntology ont : ontologies) {
      if (!ont.equals(targetOntology)) {

        // move the axioms
        for (OWLAxiom ax : ont.getAxioms()) {
          changes.add(new AddAxiom(targetOntology, ax));
        }

        // move ontology annotations
        for (OWLAnnotation annot : ont.getAnnotations()) {
          changes.add(new AddOntologyAnnotation(targetOntology, annot));
        }

        if (!targetOntology.getOntologyID().isAnonymous()) {
          // move ontology imports
          for (OWLImportsDeclaration decl : ont.getImportsDeclarations()) {
            if (ontologies.contains(ont.getOWLOntologyManager().getImportedOntology(decl))) {
              continue;
            }
            Optional<IRI> defaultDocumentIRI =
                targetOntology.getOntologyID().getDefaultDocumentIRI();
            if (defaultDocumentIRI.isPresent() && !decl.getIRI().equals(defaultDocumentIRI.get())) {
              changes.add(new AddImport(targetOntology, decl));
            } else {
              logger.warn(
                  "Merge: ignoring import declaration for ontology "
                      + targetOntology.getOntologyID()
                      + " (would result in target ontology importing itself).");
            }
          }
        }
      }
    }
    try {
      owlOntologyManager.applyChanges(changes);
    } catch (OWLOntologyChangeException e) {
      ErrorLogPanel.showErrorDialog(e);
    }
  }
コード例 #6
0
 public void storeFromTo(OWLOntology from, HGDBOntology to) {
   final Set<OWLAxiom> axioms = from.getAxioms();
   int i = 0;
   for (OWLAxiom axiom : axioms) {
     to.applyChange(new AddAxiom(to, axiom));
     i++;
     if (i % 5000 == 0) {
       System.out.println("storeFromTo: Axioms: " + i);
     }
   }
   System.out.println("storeFromTo: Axioms: " + i);
   // manager.addAxioms(newOnto, axioms);
   // Add Ontology Annotations
   for (OWLAnnotation a : from.getAnnotations()) {
     to.applyChange(new AddOntologyAnnotation(to, a));
   }
   // Add Import Declarations
   for (OWLImportsDeclaration im : from.getImportsDeclarations()) {
     to.applyChange(new AddImport(to, im));
   }
 }
コード例 #7
0
ファイル: LodeServlet.java プロジェクト: zednis/LODE
  private OWLOntology parseWithReasoner(OWLOntologyManager manager, OWLOntology ontology) {
    try {
      PelletOptions.load(new URL("http://" + cssLocation + "pellet.properties"));
      PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner(ontology);
      reasoner.getKB().prepare();
      List<InferredAxiomGenerator<? extends OWLAxiom>> generators =
          new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
      generators.add(new InferredSubClassAxiomGenerator());
      generators.add(new InferredClassAssertionAxiomGenerator());
      generators.add(new InferredDisjointClassesAxiomGenerator());
      generators.add(new InferredEquivalentClassAxiomGenerator());
      generators.add(new InferredEquivalentDataPropertiesAxiomGenerator());
      generators.add(new InferredEquivalentObjectPropertyAxiomGenerator());
      generators.add(new InferredInverseObjectPropertiesAxiomGenerator());
      generators.add(new InferredPropertyAssertionGenerator());
      generators.add(new InferredSubDataPropertyAxiomGenerator());
      generators.add(new InferredSubObjectPropertyAxiomGenerator());

      InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, generators);

      OWLOntologyID id = ontology.getOntologyID();
      Set<OWLImportsDeclaration> declarations = ontology.getImportsDeclarations();
      Set<OWLAnnotation> annotations = ontology.getAnnotations();

      Map<OWLEntity, Set<OWLAnnotationAssertionAxiom>> entityAnnotations =
          new HashMap<OWLEntity, Set<OWLAnnotationAssertionAxiom>>();
      for (OWLClass aEntity : ontology.getClassesInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }
      for (OWLObjectProperty aEntity : ontology.getObjectPropertiesInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }
      for (OWLDataProperty aEntity : ontology.getDataPropertiesInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }
      for (OWLNamedIndividual aEntity : ontology.getIndividualsInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }
      for (OWLAnnotationProperty aEntity : ontology.getAnnotationPropertiesInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }
      for (OWLDatatype aEntity : ontology.getDatatypesInSignature()) {
        entityAnnotations.put(aEntity, aEntity.getAnnotationAssertionAxioms(ontology));
      }

      manager.removeOntology(ontology);
      OWLOntology inferred = manager.createOntology(id);
      iog.fillOntology(manager, inferred);

      for (OWLImportsDeclaration decl : declarations) {
        manager.applyChange(new AddImport(inferred, decl));
      }
      for (OWLAnnotation ann : annotations) {
        manager.applyChange(new AddOntologyAnnotation(inferred, ann));
      }
      for (OWLClass aEntity : inferred.getClassesInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }
      for (OWLObjectProperty aEntity : inferred.getObjectPropertiesInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }
      for (OWLDataProperty aEntity : inferred.getDataPropertiesInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }
      for (OWLNamedIndividual aEntity : inferred.getIndividualsInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }
      for (OWLAnnotationProperty aEntity : inferred.getAnnotationPropertiesInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }
      for (OWLDatatype aEntity : inferred.getDatatypesInSignature()) {
        applyAnnotations(aEntity, entityAnnotations, manager, inferred);
      }

      return inferred;
    } catch (FileNotFoundException e1) {
      return ontology;
    } catch (MalformedURLException e1) {
      return ontology;
    } catch (IOException e1) {
      return ontology;
    } catch (OWLOntologyCreationException e) {
      return ontology;
    }
  }