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 打开本体时,个人仍然存在。

你能告诉我如何从 Eclipse 中删除个人以免出现在 Protege 中吗?

4

1 回答 1

0

之后你保存了本体吗?

您需要manager.saveOntology(localPicture);在应用更改后调用,否则它们仅对本体的内存副本有效。

于 2014-12-03T19:15:01.557 回答