Java OWL替换对象和数据属性值

Java OWL替换对象和数据属性值,java,ontology,semantic-web,protege,owl-api,Java,Ontology,Semantic Web,Protege,Owl Api,我编写了以下代码来替换对象属性值: public void changeObjectPropertyValue(String ind, String propertyFragment, String newValueFragment) { OWLNamedIndividual individualToReplaceValueOn = factory.getOWLNamedIndividual(prefix + ind); OWLNamedIndividual

我编写了以下代码来替换对象属性值:

 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);
    }
public void changeObjectPropertyValue(字符串ind、字符串propertyFragment、字符串newValueFragment){
OWLNamedIndividual individualToReplaceValueOn=factory.getOWLNamedIndividual(前缀+ind);
OWLNamedIndividual newValueInd=factory.getOWLNamedIndividual(前缀+newValueFragment);
OWLObjectProperty theObjectProperty=factory.getOWLObjectProperty(前缀+propertyFragment);
OWLDValue=EntitySearcher.getObjectPropertyValues(individualToReplaceValueOn,TheObject属性,ont).findFirst().get();
OWLAxiom oldAxiom=factory.GetowlObjectPropertyServationAXIOM(
对象属性,
个人价值观,
奥尔德值);
OWLAxiom newAxiom=factory.getowlObjectPropertyServationAXIOM(
对象属性,
个人价值观,
纽瓦伦德);
列表更改=新向量();
添加(新的RemoveAxiom(ont,oldAxiom));
添加(新的AddAxiom(ont,newAxiom));
经理。申请变更(变更);
}

我想知道这是否是替换值的正确方法,以及OWLAPI库中是否有这样做的方法?

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