1

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

但我想添加我自己定义的注释而不是 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));

对此的任何帮助都将受到高度赞赏。

谢谢

4

1 回答 1

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));
于 2014-11-26T19:56:44.313 回答