A Haskell parser and pretty printer for various dialects of the OWL 2 Web Ontology Language. Its current version is able to parse and pretty print the Manchester and the Functional syntax of OWL2.
DISCLAIMER: This is a work in progress and by no means complete
- Language: Haskell
- Environment/Build Tools: Nix/Cabal
- Parser: megaparsec
- There are many keys that are required to be annotated. However:
- Annotations usually are optional and
- In the example at the end of the specification page, there are no annotations for these cases, something that increases my suspicion that the grammar is not correct for the following cases:
dataFrame
->EquivalentTo:
classFrame
->DisjointUnionOf:
classFrame
->HasKey:
objectPropertyFrame
->SubPropertyChain:
dataPropertyFrame
->Characteristics:
misc
-> all cases
- Based on the grammar, a
classFrame
is defined by either aHasKey
construct or by many sub-constructs of a list of 5 different sub-constructs. However, in the example, there is theClass: Person
which contains bothHasKey
and the other sub-constructs as well. This means that theHasKey
in the grammar should not be an alternative (i.e.|
) but it should be an optional (i.e.[...]
) - The list of alternatives in the
annotationPropertyFrame
is probably wrong: The closing '}' should include all alternatives and not only the annotations - Should
annotations <NT>2List
be equal to<NT>AnnotatedList
where there are at least 2<NT>
in it? NO (see Update)- If that is the case, then the AST is not correct, as the first example will be able to parse a list of
NT
s which may be accompanied by a list of annotations (i.e. the annotations are applied to the list), while in the second example, eachNT
can be accompanied by a list of annotations - If this is not the case, then I think that the
annotations
should be optional (i.e.[annotations]
). As it is now all the annotations included in the types are required! - In my parser, I followed the second solution and converted all `annotations to optional
- Update: It seems that
annotations <NT>2List
is not equal to<NT>AnnotatedList
; The elements that use the first syntax (e.g. all themisc
) define the annotations for the element itself and not its members, so there must be only a single annotation list (i.e.annotations
) and not an annotation per member. However theannottation
should have been inside square brakets as annotaitons are optional (tested in Protege) - Based on the syntax, a
conjunction
likeclassIRI that { :ind1, :ind2 }
is not permitted, as theclassIRI
should be followed by the keywordthat
and then arestriction
(with an optionnot
between them). HoweverProtege
parses this syntax without an issue, while Functional Syntax seems to allow that as well.- Also the
classIRI
does not seem to be correct either, as in place of a class iri we can use other descriptions as well. E.g.(classIRI1 or classIRI2) that { :ind1, :ind2 }
can be successfully parsed
- Also the
- Based on its syntax tree an
ObjectPropertyFrame
should describe axioms of anobjectPropertyIRI
. However, OWL2 (at least based on Functional Syntax) seems to support arbitraryObjectPropertyExpression
. For example in Manchester syntax you cannot defined the following axiom: - The inverse of the object-property-A is sub-property of the inverse of object-property-B
- In Functional you can model this as:
SubObjectPropertyOf(ObjectInverseOf(test-ont:ObjectProp2) ObjectInverseOf(test-ont:ObjectProp1))
- Note: Protege is able to parse it and represent it on the UI (albeit, to the Usage window only), but trying to save the ontology in Manchester format, the axiom will be discarder
- If that is the case, then the AST is not correct, as the first example will be able to parse a list of
- Based on the syntax a
DataFrame
can have at most oneEquivalentTo
data range. However:- Functional syntax supports equivalence with more than a single data range
- Protege accepts more than a single data range and print them in a comma separated list when Manchester format is selected:
EquivalentTo: owl:real, not xsd:negativeInteger
- However when annotations are being attahced to the equivalent data ranges, Protege does not save them in the exproted (Manchester formatted) file. Also, Protege is not able to parse a (Manchester formatted) file, which contains annotations in this place:
EquivalentTo: Annotations: rdfs:comment "Some comment" not xsd:negativeInteger
- Protege does not seem to support multiple data property expressions in a single
DataAllValuesFrom
class expression. For example it was not possible to parse:EquivalentClasses(test-ont:Test1 DataAllValuesFrom(test-ont:dataProp1 test-ont:dataPro2 xsd:integer))
- However the the specifications define this constructor as:
DataSomeValuesFrom := 'DataSAllValuesFrom' '(' DataPropertyExpression { DataPropertyExpression } DataRange ')'
- The same applies for
DataDomeValuesFrom
class expression
- However the the specifications define this constructor as:
- It seems that even though Protege can parse General class axioms in Manchester format, it does not save them back
- Steps to reproduce:
- Add the line
EquivalentClasses: cls1 or cls2, cls3 and cls4
to the file - Import the ontology. You can see the assertion in the General class axioms window
- Make any change in order to trigger Protege to save the file
- Save the ontology in Manchester format
- Open the file with an editor; The assertion is not there
- Add the line
- Steps to reproduce: