'How to parse syntax using OWL API?
I am a beginner in OWL API and am learning how to parse functional syntax. So far I have been unable to do it, and cannot figure out where I am going wrong. For example, consider a short and simple OWL file having the following(just a random example) -
EquivalentClasses(:TestPizza ObjectIntersectionOf(DataMinCardinality(20 :hasToppingValue xsd:double) :Pizza))
The problem is I can't even create an OWLFunctionalSyntaxParser variable since it is showing undefined( I am using the latest version - 5.1.18).
Could anyone help by providing a code example on how to parse it?
Solution 1:[1]
There is a misunderstanding here on what parsing functional syntax looks like. A functional syntax axiom is not self standing - it must be part of an ontology. This would include prefix declarations and an ontology declaration.
For Manchester syntax, there are classes to parse a string that represents just an axiom or a class expression; however, that requires manual management of namespaces. For functional syntax, these classes do not exist. To parse a string, it must contain an ontology declaration, as a minimum. Then parsing happens just like for any other language - e.g., with a StringDocumentSource to take the string as input, and passed to an OWLOntologyManager for parsing. There are examples on the OWLAPI wiki on how to do that.
StringDocumentSource input=new StringDocumentSource("functional syntax string");
OWLOntology ontology = ontologyManager.loadOntologyFromOntologyDocument(input);
Axioms are then available:
// stream of axioms
ontology.axioms();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
