Add my defined anntation to an individual in owl

102 views Asked by At

I have an ontology for movies and I'm using OWL-API and I have added to it some individuals. I want to add some annotations that I have defined. I found here how I can add label to individual in this link [ How to add rdfs:label to OWLIndividual via OWLAPI?

but I want to add my own defined annotation instead of rdfs:label for example I want to add rdfs:Movie_Name . the expected results as follow:

   <!-- 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>

The code that I have copy from the link above is as follow:

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

Any help with this is highly appreciated.

Thanks

1

There are 1 answers

0
Ignazio On BEST ANSWER

In order to use any annotation property you wish to use, the snippet above must be modified this way:

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