OWL API对象属性注释创建

时间:2014-06-30 15:41:38

标签: api owl ontology object-properties

是否有人可以帮助我使用" OWL API" ??

生成此ObjectPropertyRange
<ObjectPropertyRange>
    <Annotation>
        <AnnotationProperty abbreviatedIRI="owl:backwardCompatibleWith"/>
        <IRI>#ProgramLanguage</IRI>
    </Annotation>
    <ObjectProperty IRI="#specifiedBy"/>
    <ObjectMaxCardinality cardinality="1">
        <ObjectProperty IRI="#specifiedBy"/>
        <Class IRI="#Grammars"/>
    </ObjectMaxCardinality>
</ObjectPropertyRange> 

这是我过去3天的表现....

<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);

1 个答案:

答案 0 :(得分:1)

提供完整的代码段:

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));

此时,将公理添加到本体并以首选格式保存。从示例中,我猜测了OWL / XML。

问题和答案可在https://github.com/owlcs/owlapi/issues/235获取,以获取进一步的评论,讨论以及任何其他不适合StackOverflow格式的活动。

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

相关问题