Discipulos
Discipulos

Reputation: 469

Exporting Inferred Axiom together with Annotation in OWL API

I'am exporting all inferred axioms from an ontology using the following:

   List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<>();
         gens.add(new InferredSubClassAxiomGenerator());  
         gens.add(new InferredClassAssertionAxiomGenerator());
         gens.add( new InferredDisjointClassesAxiomGenerator());
         gens.add( new InferredEquivalentClassAxiomGenerator());
         gens.add( new InferredEquivalentDataPropertiesAxiomGenerator());
         gens.add( new InferredEquivalentObjectPropertyAxiomGenerator());
         gens.add( new InferredInverseObjectPropertiesAxiomGenerator());
         gens.add( new InferredObjectPropertyCharacteristicAxiomGenerator());
         gens.add( new InferredPropertyAssertionGenerator());
         gens.add( new InferredSubDataPropertyAxiomGenerator());
         gens.add(new InferredDataPropertyCharacteristicAxiomGenerator());
         gens.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
         gens.add( new InferredSubObjectPropertyAxiomGenerator());
         reasoner.flush();
         reasoner.getKB().realize(); 
         InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
         OWLOntology infOnt = manager.createOntology();
         iog.fillOntology(reasoner.getManager().getOWLDataFactory(), infOnt);

Now, I want to export all of the Annotation (labels and comments) from the ontology, putting them in the new one. How Can I Do ? Many thanks.

Upvotes: 1

Views: 296

Answers (1)

Discipulos
Discipulos

Reputation: 469

I have resolved just copying the annotation axioms from the ontology source to the destination:

 for(OWLOntology o : manager.getImportsClosure(src)) {
         for(OWLAnnotationAssertionAxiom ax : o.getAxioms(AxiomType.ANNOTATION_ASSERTION)) {
        manager.applyChange(new AddAxiom(infOnt, ax));
             }
         }

I don't know if there is a better way, but It works.

Upvotes: 1

Related Questions