Search code examples
annotationsowlontologypellet

OWL2: Is it possible put Annotation on an ObjectIntersectionOf?


I know I can put annotations on a SubClassOf relation:

SubClassOf(
    Annotation(rdfs:comment "This annotation is valid")
    ObjectIntersectionOf(
        ObjectHasValue(:prop1 :instance1) 
        ObjectHasValue(:prop2 :instance2)
    )
    ObjectHasValue(:prop3 :instance3)
)

However, what I really wanted to do is this:

SubClassOf(
    ObjectIntersectionOf(
        Annotation(rdfs:comment "This annotation is invalid")
        ObjectHasValue(:prop1 :instance1) 
        ObjectHasValue(:prop2 :instance2)
    )
    ObjectHasValue(:prop3 :instance3)
)

What I want is to create an annotation meaningful to all objects with the relations :prop1 :instance1 and :prop2 :instance, and not to the subclass relation.

I don't want to create a class for the ObjectIntersectionOf, as I will have thousands of such classes on my real example.

Running pellet 2.3.1 on the file below yields the following error:

$ pellet.sh explain draft2.owl

There are 1 input files:
./draft2.owl
Start loading
org.semanticweb.owlapi.io.UnparsableOntologyException: Problem parsing file:/home/users/djogo/Desktop/ontologia%20tnm/draft2.owl
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: file:/home/users/djogo/Desktop/ontologia%20tnm/draft2.owl; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: file:/home/users/djogo/Desktop/ontologia%20tnm/draft2.owl; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered "" at line 8, column 9.
Was expecting one of:
     (Line 7)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 6, column 12.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " <NAME> "Prefix "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered Prefix at line 1 column 1. Expected one of:
    DifferentIndividuals:
    Individual:
    Class:
    AnnotationProperty:
    Import:
    DisjointClasses:
    ObjectProperty:
    Datatype:
    EquivalentClasses:
    SameIndividual:
    Prefix:
    DataProperty:
    DisjointProperties:
    ValuePartition:
 (Line 1)


    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:236)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:880)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:818)
    at com.clarkparsia.pellet.owlapiv3.OWLAPILoader.parseFile(OWLAPILoader.java:142)
    at org.mindswap.pellet.KBLoader.parse(KBLoader.java:99)
    at com.clarkparsia.pellet.owlapiv3.OWLAPILoader.parse(OWLAPILoader.java:128)
    at org.mindswap.pellet.KBLoader.createKB(KBLoader.java:65)
    at pellet.PelletCmdApp.getKB(PelletCmdApp.java:210)
    at pellet.PelletCmdApp.getKB(PelletCmdApp.java:198)
    at pellet.PelletExplain.parseArgs(PelletExplain.java:204)
    at pellet.Pellet.run(Pellet.java:104)
    at pellet.Pellet.main(Pellet.java:59)

draft2.owl

Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Prefix(:=<http://cipe.accamargo.org.br/ontologias/tnm.owl#>)

Ontology(<http://cipe.accamargo.org.br/ontologias/tnm.owl>

SubClassOf(
    ObjectIntersectionOf(
        Annotation(rdfs:comment "This annotation is invalid")
        ObjectHasValue(:prop1 :instance1) 
        ObjectHasValue(:prop2 :instance2)
    )
    ObjectHasValue(:prop3 :instance3)
)

Solution

  • No, I don't think you can do this. The OWL 2 spec allows for annotations of ontologies, axioms, and entities, and complex class expressions are neither of those (see §10 Annotations).

    Pellet has nothing to do with this, you get the error from the OWL API FSS parser since your ontology is syntactically invalid.