1

Protege で作成されたオノロジーがあります。Eclipse を使用してオントロジーをロードしました。次のコードを使用して、オントロジーから特定の個人を削除しようとしました。

File file = new File("D:/diana/e/2012_2013/d/protege/picture8.owl");
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology localPicture = manager.loadOntologyFromOntologyDocument(file);
OWLReasonerFactory reasonerFactory = new StructuralReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(localPicture, config);
OWLDataFactory fac = manager.getOWLDataFactory();

//the individual that I want to delete
OWLNamedIndividual ind = fac.getOWLNamedIndividual(IRI.create("http://www.semanticweb.org/diana/ontologies/2013/0/picture4.owl#Water1"));
OWLEntityRemover remover = new OWLEntityRemover(Collections.singleton(localPicture));
remover.visit(ind);
// or ind.accept(remover);
manager.applyChanges(remover.getChanges());

個体は削除されたようですが、Protege でオントロジーを開くと、個体はまだ存在しています。

Protege に表示されないようにするには、Eclipse から個人を削除する方法を教えてください。

4

1 に答える 1

0

その後、オントロジーを保存しましたか?

変更を適用した後に呼び出す必要があります。そうしないmanager.saveOntology(localPicture);と、オントロジーのメモリ内コピーに対してのみ有効になります。

于 2014-12-03T19:15:01.557 に答える