OWL API這裏有涼爽的文檔:http://owlapi.sourceforge.net/documentation.html
因此,創建一個類的個體:
OWLClass person = dataFactory.getOWLClass(":Person", pm);
OWLNamedIndividual mary = dataFactory.getOWLNamedIndividual(":Mary", pm);
OWLClassAssertionAxiom classAssertion = dataFactory.getOWLClassAssertionAxiom(person, mary);
manager.addAxiom(ontology, classAssertion);
要添加一些屬性:
OWLIndividual matthew = dataFactory.getOWLNamedIndividual(IRI.create(base + "#matthew"));
OWLIndividual peter = dataFactory.getOWLNamedIndividual(IRI.create(base + "#peter"));
OWLObjectProperty hasFather = dataFactory.getOWLObjectProperty(IRI.create(base + "#hasFather"));
OWLObjectPropertyAssertionAxiom assertion = dataFactory.getOWLObjectPropertyAssertionAxiom(hasFather, matthew, peter);
也有一個推理器的例子,但它更長,所以檢查你自己。
如果瑪麗有一個父親,我該怎麼辦? –