如何使用推理器获取 owl 中的个体类别
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.loadOntologyFromOntologyDocument(new StringDocumentSource(KOALA));
IRI ontologyIRI = IRI.create("http://www.semanticweb.org/xxxxx/ontologies/2017/10/ontology");
OWLDataFactory factory = manager.getOWLDataFactory();
OWLIndividual john = factory.getOWLNamedIndividual(IRI.create(ontologyIRI + "#John"));
OWLDataPropertyExpression hasConnexion= factory.getOWLDataProperty(IRI.create(ontologyIRI + "#hasConnexion"));
OWLDataPropertyAssertionAxiom axiom = factory.getOWLDataPropertyAssertionAxiom(hasConnexion, john, 3);
AddAxiom addAxiom = new AddAxiom(ontology, axiom);
manager.applyChange(addAxiom);
manager.saveOntology(ontology, new StreamDocumentTarget(System.out));
//reasoner
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
OWLClass myClass= fac.getOWLClass(IRI.create("http://www.semanticweb.org/xxxxx/ontologies/2017/10/ontology#hasConnexion"));
NodeSet<OWLNamedIndividual> individuals = reasoner.getInstances(myClass,
false);
for (Node<OWLNamedIndividual> i : individuals)
{
System.out.println(i.getClass());
}
我希望结果是每个人的类别,但推理器没有给出结果。在 protege 中它运行良好,但是当我使用我的本体并尝试使用 owl api 制作它时,我没有得到任何结果