【问题标题】:OWL replace object and data property valueOWL 替换对象和数据属性值
【发布时间】:2021-01-17 06:14:04
【问题描述】:

我已经编写了这段代码来替换对象属性值:

 public void changeObjectPropertyValue(String ind, String propertyFragment, String newValueFragment) {

        OWLNamedIndividual individualToReplaceValueOn = factory.getOWLNamedIndividual(prefix + ind);
        OWLNamedIndividual newValueInd = factory.getOWLNamedIndividual(prefix + newValueFragment);
        OWLObjectProperty theObjectProperty = factory.getOWLObjectProperty(prefix + propertyFragment);
        OWLIndividual theOldValue = EntitySearcher.getObjectPropertyValues(individualToReplaceValueOn, theObjectProperty, ont).findFirst().get();

        OWLAxiom oldAxiom = factory.getOWLObjectPropertyAssertionAxiom(
                theObjectProperty,
                individualToReplaceValueOn,
                theOldValue);

        OWLAxiom newAxiom = factory.getOWLObjectPropertyAssertionAxiom(
                theObjectProperty,
                individualToReplaceValueOn,
                newValueInd);

        List<OWLOntologyChange> changes = new Vector<OWLOntologyChange>();

        changes.add(new RemoveAxiom(ont, oldAxiom));
        changes.add(new AddAxiom(ont, newAxiom));
        manager.applyChanges(changes);
    }

我想知道这是否是替换值的正确方法以及 OWLAPI 库中是否有方法可以做到这一点?

【问题讨论】:

    标签: java ontology semantic-web protege owl-api


    【解决方案1】:

    这是正确的 - 并且是在 OWL API 中进行此类更改的唯一方法。公理是不可变的对象,因此除了重新创建公理并更改过程中需要修改的部分之外,没有其他方法可以修改公理。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-29
      • 2018-12-09
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      相关资源
      最近更新 更多