【问题标题】:Delete ontology individuals with OWL API not deleted in Protege使用未在 Protege 中删除的 OWL API 删除本体个体
【发布时间】:2014-12-03 16:37:34
【问题描述】:

我在 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 中吗?

【问题讨论】:

    标签: eclipse protege owl-api


    【解决方案1】:

    你后来保存了本体吗?

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

    【讨论】:

    • 我正在考虑它,但我是 OWL 的新手,我自学观看文档,所以我尝试了 manager.saveOntology(localPicture, new StreamDocumentTarget(new ByteArrayOutputStream()));不知道参数的含义,它没有工作。你的建议有效。谢谢。
    猜你喜欢
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    • 2014-12-03
    • 1970-01-01
    • 2014-05-03
    • 1970-01-01
    • 2013-01-01
    • 2014-01-27
    相关资源
    最近更新 更多