简体   繁体   English

使用在Protege中未删除的OWL API删除本体个体

[英]Delete ontology individuals with OWL API not deleted in Protege

I have an onology created in Protege. 我有一个在Protege中创建的本体。 I loaded the ontology using Eclipse. 我使用Eclipse加载了本体。 I tried to delete a specific individual from ontology using the following code: 我尝试使用以下代码从本体中删除特定个人:

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());

It seems that the individual was deleted, but when I open the ontology with Protege the individual is still there. 看来该个人已被删除,但是当我使用Protege打开本体时,该个人仍在那儿。

Could you tell me how can I delete the individual from Eclipse so as not to appear in Protege? 您能告诉我如何从Eclipse中删除个人,使其不出现在Protege中吗?

Have you saved the ontology afterwards? 之后您是否保存了本体?

You need to call manager.saveOntology(localPicture); 您需要致电manager.saveOntology(localPicture); after applying the changes or they are only effective for the in memory copy of the ontology. 应用更改后,否则它们仅对本体的内存中副本有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM