我尝试从理由程序(Hermit 1.3.8.4(和Owlapi(3.4.10(中检索属性主张。在这张照片中,我想检索" Israndfather Sandro,Israndfather Sergio"。
图片 - 对象属性断言
我尝试使用Ignazio答案:https://stackoverflow.com/a/37497541/3760251
以horridge示例,但是owl api更改了签名,我不知道该如何使用它。https://www.javatips.net/api/owl-master/owlapi-master/tools/src/main/java/java/org/semanticweb/semanticweb/owlapi/itil/inferredsubobsptrredsubobsptropertpropertyaxiomgenerator.java
因此,如果您有一个来自sewredobjectPropertyaxiomgenerator的Addaxioms方法的示例,我会很感激。
pefleRedObjectPropertyaxiomgenerator generator = new celebredobjectPropertyaxiomgenerator(({ @Override 受保护的void Addaxioms(猫头鹰实体,猫头鹰推理器,owldatafactory dataFactory,设置结果({ }}
谢谢,
我从Ignazio中找到了一个很棒的代码:
我已经对您的代码进行了较小的更改,并使用Owlapi 4.3.1-Snapshot和Hermit和Hermit 1.3.8.431-Snapshot(这些版本包含第646页中详细介绍的修复程序(
>输出文件包含对象属性:
public static void main(String[] args) throws Exception {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntology(
IRI.create("https://raw.githubusercontent.com/owlcs/pizza-ontology/master/pizza.owl"));
OWLDataFactory df = manager.getOWLDataFactory();
Configuration configuration = new Configuration();
configuration.ignoreUnsupportedDatatypes = true;
ReasonerFactory rf = new ReasonerFactory();
OWLReasoner reasoner = rf.createReasoner(ontology, configuration);
boolean consistencyCheck = reasoner.isConsistent();
if (consistencyCheck) {
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY,
InferenceType.CLASS_ASSERTIONS, InferenceType.OBJECT_PROPERTY_HIERARCHY,
InferenceType.DATA_PROPERTY_HIERARCHY, InferenceType.OBJECT_PROPERTY_ASSERTIONS);
List<InferredAxiomGenerator<? extends OWLAxiom>> generators = new ArrayList<>();
generators.add(new InferredSubClassAxiomGenerator());
generators.add(new InferredClassAssertionAxiomGenerator());
generators.add(new InferredDataPropertyCharacteristicAxiomGenerator());
generators.add(new InferredEquivalentClassAxiomGenerator());
generators.add(new InferredEquivalentDataPropertiesAxiomGenerator());
generators.add(new InferredEquivalentObjectPropertyAxiomGenerator());
generators.add(new InferredInverseObjectPropertiesAxiomGenerator());
generators.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
// NOTE: InferredPropertyAssertionGenerator significantly slows down
// inference computation
generators.add(new org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator());
generators.add(new InferredSubClassAxiomGenerator());
generators.add(new InferredSubDataPropertyAxiomGenerator());
generators.add(new InferredSubObjectPropertyAxiomGenerator());
List<InferredIndividualAxiomGenerator<? extends OWLIndividualAxiom>> individualAxioms =
new ArrayList<>();
generators.addAll(individualAxioms);
generators.add(new InferredDisjointClassesAxiomGenerator());
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, generators);
OWLOntology inferredAxiomsOntology = manager.createOntology();
iog.fillOntology(df, inferredAxiomsOntology);
File inferredOntologyFile = new File("output.txt");
// Now we create a stream since the ontology manager can then write to that stream.
try (OutputStream outputStream = new FileOutputStream(inferredOntologyFile)) {
// We use the same format as for the input ontology.
manager.saveOntology(inferredAxiomsOntology, outputStream);
}
} // End if consistencyCheck
else {
System.out.println("Inconsistent input Ontology, Please check the OWL File");
}
}