簡體   English   中英

使用在Protege中未刪除的OWL API刪除本體個體

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

我有一個在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中嗎?

之后您是否保存了本體?

您需要致電manager.saveOntology(localPicture); 應用更改后,否則它們僅對本體的內存中副本有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM