在OWL API中将推断的Axiom与Annotation一起导出

问题描述 投票:1回答:1

我使用以下方法从本体中导出所有推断的公理:

   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);

现在,我想从本体导出所有注释(标签和注释),将它们放在新的注释中。我能怎么做 ?非常感谢。

java semantic-web owl-api
1个回答
1
投票

我已经解决了将注释公理从本体源复制到目标的问题:

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

我不知道是否有更好的方法,但它有效。

© www.soinside.com 2019 - 2024. All rights reserved.