将我定义的注释添加到owl中的个体

时间:2014-11-26 17:34:05

标签: semantics owl owl-api

我有一个电影本体,我正在使用OWL-API,我已经添加了一些个人。我想添加一些我已经定义的注释。我在这里找到了如何在此链接[How to add rdfs:label to OWLIndividual via OWLAPI?

中为个人添加标签

但我想添加自己定义的注释而不是rdfs:label,例如我想添加rdfs:Movie_Name。预期结果如下:

   <!-- http://www.daml.org/2003/01/movienight/movienight#Fury -->

    <owl:NamedIndividual rdf:about="http://www.daml.org/2003/01/movienight/movienight#Fury">
        <rdf:type     rdf:resource="http://www.daml.org/2003/01/movienight/movienight/Movies_Genre#Action"/>
        <rdf:type rdf:resource="http://www.daml.org/2003/01/movienight/movienight/Movies_Genre#Drama"/>
        <rdfs:label>April, 1945. As the Allies make their final push in the European Theatre, a battle-hardened army sergeant named Wardaddy commands a Sherman tank and his five-man crew on a deadly mission behind enemy lines. Out-numbered, out-gunned, and with a rookie soldier thrust into their platoon, Wardaddy and his men face overwhelming odds in their heroic attempts to strike at the heart of Nazi Germany.</rdfs:label>
        <rdfs:Movie_Name>Fury</rdfs:Movie_Name>
        <rdfs:Directed_By> David Ayer</rdfs:Directed_By>
        <rdfs:Year_of_production>2014</rdfs:Year_of_production>
        <rdfs:Stars> Brad Pitt, Shia LaBeouf, Logan Lerman</rdfs:Stars>
        <rdfs:Country>USA</rdfs:Country>
     </owl:NamedIndividual>

我从上面链接中复制的代码如下:

    OWLAnnotation Movie_Name =
  factory.getOWLAnnotation( 
    factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()), lbl);
        OWLAxiom axiomAA =     factory.getOWLAnnotationAssertionAxiom(Cast.asOWLNamedIndividual().getIRI(), label);
manager.applyChange(new AddAxiom(ontology, axiom));

非常感谢任何帮助。

由于

1 个答案:

答案 0 :(得分:1)

为了使用您想要使用的任何注释属性,必须以这种方式修改上面的代码段:

OWLAnnotation Movie_Name = factory.getOWLAnnotation( 
factory.getOWLAnnotationProperty(IRI.create("full iri for your property here")), lbl);
OWLAxiom axiomAA = factory.getOWLAnnotationAssertionAxiom(Cast.asOWLNamedIndividual().getIRI(), label);
manager.applyChange(new AddAxiom(ontology, axiom));