我想用本体和颗粒推理器进行分类。Pellet 有一个功能(即实现())来为个人找到最具体的。我已经尝试过,但它不起作用,任何人都可以提供一些帮助或给我一些例子。
<Class rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#HavingDrink">
<equivalentClass>
<Class>
<intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#PersonalActivity"/>
<Restriction>
<onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#hasActor"/>
<allValuesFrom>
<Class>
<intersectionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#Person"/>
<Restriction>
<onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#hasCurrentSymbolicLocation"/>
<someValuesFrom rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#Kitchen"/>
</Restriction>
<Restriction>
<onProperty rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#usingArtifact"/>
<someValuesFrom>
<Class>
<unionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#CupsCupboard"/>
<rdf:Description rdf:about="http://webmind.dico.unimi.it/CARE/locont.owl#Fridge"/>
</unionOf>
</Class>
</someValuesFrom>
</Restriction>
</intersectionOf>
</Class>
</allValuesFrom>
</Restriction>
</intersectionOf>
</Class>
</equivalentClass>
<rdfs:subClassOf rdf:resource="http://webmind.dico.unimi.it/CARE/locont.owl#PersonalActivity"/>
</Class>
例如,HavingDrink 是活动类之一。现在我创建一个个人及其 ObjectProperty:
String file = "file:///home/uqjwen/workspace/Owlapi/snapshot.owl#";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ont = manager.loadOntology(IRI.create(file));
OWLDataFactory fac = manager.getOWLDataFactory();
PrefixManager pm = new DefaultPrefixManager(IRI.create("http://webmind.dico.unimi.it/CARE/locont.owl").toString());
//////////create hasActor property///////////////////////////////////////
OWLNamedIndividual currentActivity = fac.getOWLNamedIndividual("#alice_activity", pm);
OWLNamedIndividual alice = fac.getOWLNamedIndividual("#alice", pm);
OWLObjectProperty hasActor = fac.getOWLObjectProperty("#hasActor", pm);
OWLObjectPropertyAssertionAxiom propertyAssertion = fac
.getOWLObjectPropertyAssertionAxiom(hasActor,currentActivity,alice);
manager.addAxiom(ont, propertyAssertion);
////////////create hasCurrentSymbolicLocation ////////
OWLNamedIndividual kitchen = fac.getOWLNamedIndividual("#Kitchen", pm);
OWLObjectProperty hasLocation = fac
.getOWLObjectProperty("#hasCurrentSymbolicLocation", pm);
OWLObjectPropertyAssertionAxiom locationAssertion = fac
.getOWLObjectPropertyAssertionAxiom(hasLocation,alice,kitchen);
manager.addAxiom(ont, locationAssertion);
/////////////create using actifact //////////////
OWLNamedIndividual cc = fac.getOWLNamedIndividual("#cups_cupboard", pm);
OWLObjectProperty usingArtifact = fac
.getOWLObjectProperty("#usingArtifact", pm);
OWLObjectPropertyAssertionAxiom artifactAssertion =fac
.getOWLObjectPropertyAssertionAxiom(usingArtifact, alice, cc);
manager.addAxiom(ont, artifactAssertion);
OWLNamedIndividual fridge = fac.getOWLNamedIndividual("#fridge", pm);
artifactAssertion =fac
.getOWLObjectPropertyAssertionAxiom(usingArtifact, alice, fridge);
manager.addAxiom(ont, artifactAssertion);
//////////////reason
PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );
System.out.println(reasoner.isConsistent());
reasoner.getKB().classify();
reasoner.getKB().realize();
NodeSet<OWLClass> types = reasoner.getTypes(currentActivity, true);
它应该返回 HaveDrink 类,但它没有。