如何使用 OWLAPI 获取对象 属性 的个人集
How to get Individuals set of Object Property with OWLAPI
拜托,我想使用 OWLAPI 通过 java 程序解析以下 ontology。
<ObjectPropertyAssertion>
<ObjectProperty IRI="http://onto1#creator"/>
<NamedIndividual IRI="Mark1"/>
<NamedIndividual IRI="Car1"/>
</ObjectPropertyAssertion>
<ObjectPropertyAssertion>
<ObjectProperty IRI="http://onto1#creator"/>
<NamedIndividual IRI="Mark2"/>
<NamedIndividual IRI="Car2"/>
</ObjectPropertyAssertion>
输出:
- Mark1 --> Car1
- Mark2 --> Car2
提前感谢您的帮助
您需要先提取您ontology中的个体,然后要求OWL API
找到分配给这些个体的对象属性的值:
Set<OWLNamedIndividual> inds=localOntology.getIndividualsInSignature();
for (OWLNamedIndividual ind: inds){
System.out.println(ind.getObjectPropertyValues(localOntology));
}
或者您可以使用 OWLDataFactory 作为
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getDataFactory();
Set<OWLNamedIndividual> inds = localOntology.getIndividualsInSignature();
for (OWLNamedIndividual ind: inds){
System.out.println(ind.getObjectPropertyValues(factory.getOWLObjectProperty(IRI.create("Put the iri of the property here")), localOntology));
}
尽管牢记System.out.println(ind.getObjectPropertyValues(factory.getOWLObjectProperty(IRI.create("Put the iri of the property here")), localOntology));
returns一个Set<OWLIndividual>
这样做的好处是可以准确地找到您想要使用的 属性 而不是特定个人的所有属性。
拜托,我想使用 OWLAPI 通过 java 程序解析以下 ontology。
<ObjectPropertyAssertion>
<ObjectProperty IRI="http://onto1#creator"/>
<NamedIndividual IRI="Mark1"/>
<NamedIndividual IRI="Car1"/>
</ObjectPropertyAssertion>
<ObjectPropertyAssertion>
<ObjectProperty IRI="http://onto1#creator"/>
<NamedIndividual IRI="Mark2"/>
<NamedIndividual IRI="Car2"/>
</ObjectPropertyAssertion>
输出:
- Mark1 --> Car1
- Mark2 --> Car2
提前感谢您的帮助
您需要先提取您ontology中的个体,然后要求OWL API
找到分配给这些个体的对象属性的值:
Set<OWLNamedIndividual> inds=localOntology.getIndividualsInSignature();
for (OWLNamedIndividual ind: inds){
System.out.println(ind.getObjectPropertyValues(localOntology));
}
或者您可以使用 OWLDataFactory 作为
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getDataFactory();
Set<OWLNamedIndividual> inds = localOntology.getIndividualsInSignature();
for (OWLNamedIndividual ind: inds){
System.out.println(ind.getObjectPropertyValues(factory.getOWLObjectProperty(IRI.create("Put the iri of the property here")), localOntology));
}
尽管牢记System.out.println(ind.getObjectPropertyValues(factory.getOWLObjectProperty(IRI.create("Put the iri of the property here")), localOntology));
returns一个Set<OWLIndividual>
这样做的好处是可以准确地找到您想要使用的 属性 而不是特定个人的所有属性。