OWL API对象属性注释创建

OWL API对象属性注释创建,api,owl,ontology,object-properties,Api,Owl,Ontology,Object Properties,是否有人可以帮助我使用“OWLAPI”生成这个ObjectPropertyRange 要提供完整的代码段,请执行以下操作: OWLDataFactory df = ... OWLAnnotationProperty p=df.getOWLAnnotationProperty(IRI.create("urn:test#backwardCompatibleWith")); OWLAnnotation ann=df.getOWLAnnotation(p, IRI.create("urn:test#l

是否有人可以帮助我使用“OWLAPI”生成这个ObjectPropertyRange


要提供完整的代码段,请执行以下操作:

OWLDataFactory df = ...
OWLAnnotationProperty  p=df.getOWLAnnotationProperty(IRI.create("urn:test#backwardCompatibleWith"));
OWLAnnotation ann=df.getOWLAnnotation(p, IRI.create("urn:test#languageDesign"));
OWLObjectProperty op=df.getOWLObjectProperty(IRI.create("urn:test#produces"));
OWLClass c = df.getOWLClass(IRI.create("urn:test#ProgramLanguage"));
OWLObjectPropertyRangeAxiom axiom=df.getOWLObjectPropertyRangeAxiom(op, c, Collections.singleton(ann));
此时,将axiom添加到本体中,并以首选格式保存。从这个例子中,我猜是OWL/XML

该问题和答案可在上获取,以供进一步评论、讨论和任何其他不符合StackOverflow格式的活动


关于添加注释时提到的不支持的操作,请注意,由OWLDataFactory创建的所有对象都是不可变的。创建对象时必须添加注释,之后不能将注释添加到现有对象。

如果您首先用更简单的语法指定要创建的公理,则可以更轻松地执行其中一些操作。在本例中,您试图说specifiedBy的范围是限制类(specifiedBy max 1语法)。这对我来说似乎有点奇怪,就像你说的:“如果由(x,y)指定,那么最多有一个z由(y,z)指定”。但是,用这些术语来考虑,可能会使您更容易理解需要编写的代码。您知道如何在内部进行注释吗?其余的我只是想弄明白…文档中有一些可能会有所帮助。如果你解决了这个问题,一定要将你的结果作为答案发布并接受它。其他人会发现你的问题,并从你找到的解决方案中受益。我已经看到了注释的示例,但OWL API上的文档很糟糕,没有帮助,因此如果你能帮助注释,那就太好了…我已经完成了其余的部分,但我无法回答,因为我是一个级别较低的成员,必须等待..嗯,你仍然可以用现在的代码更新你的问题。您已经在使用getowlsublasofaxiom,使用带有一组注释的版本有什么问题(OWLDataFactory中有两个getowlsublasofaxiom方法)?
<ObjectPropertyRange>
    <ObjectProperty IRI="#has"/>
    <ObjectMaxCardinality cardinality="1">
        <ObjectProperty IRI="#has"/>
        <Class IRI="#Quantity"/>
    </ObjectMaxCardinality>
</ObjectPropertyRange>
OWLClassExpression expression=df.getOWLObjectMaxCardinality(relations.max, objectProperty,range.getNNF());
OWLSubClassOfAxiom subClassOfAxiom=df.getOWLSubClassOfAxiom(df.getOWLClass(IRI.create(relations.class2)), expression);
OWLObjectPropertyRangeAxiom owlObjectPropertyRangeAxiom=df.getOWLObjectPropertyRangeAxiom(objectProperty,subClassOfAxiom.getSuperClass());
manager.addAxiom(new_ontology,owlObjectPropertyRangeAxiom);
OWLDataFactory df = ...
OWLAnnotationProperty  p=df.getOWLAnnotationProperty(IRI.create("urn:test#backwardCompatibleWith"));
OWLAnnotation ann=df.getOWLAnnotation(p, IRI.create("urn:test#languageDesign"));
OWLObjectProperty op=df.getOWLObjectProperty(IRI.create("urn:test#produces"));
OWLClass c = df.getOWLClass(IRI.create("urn:test#ProgramLanguage"));
OWLObjectPropertyRangeAxiom axiom=df.getOWLObjectPropertyRangeAxiom(op, c, Collections.singleton(ann));