0

I have owl file containing some axioms :

<rdfs:subClassOf>
    <owl:Restriction>
        <owl:onProperty rdf:resource="namespace#Gender"/>
        <owl:hasValue>M</owl:hasValue>
    </owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
    <owl:Restriction>
        <owl:onProperty rdf:resource="namespace#Address"/>
        <owl:minQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minQualifiedCardinality>
        <owl:onDataRange rdf:resource="&xsd;string"/>
    </owl:Restriction>
</rdfs:subClassOf>

For above two axioms protege shows readable string as :

Gender value "M"
Address min 1 xsd:string

The question is how protege generates these readable strings from OWL file ?

Also if I want to create new axiom from these strings how to do that ? (converting axiom to readable string and then convert readable string to axiom back)

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
SuhasD
  • 728
  • 2
  • 7
  • 20

1 Answers1

3

The readable format you show is Manchester OWL syntax.

In order to output an ontology in this format, you can use owl api code:

OWLOntology ontology = ...// load or create the ontology
OutputStream out = ... // any output stream will do
ontology.getOWLOntologyManager().saveOntology(ontology, new ManchesterSyntaxDocumentFormat(), out);
out.close();

Parsing a full ontology in Manchester syntax format happens like any other ontology: ontologyManager.loadOntologyFromOntologyDocument() with an input file.

Parsing single axioms is possible but much harder, because the format relies on prefixes set once for a whole ontology; so a lot of setup code is required. I would not recommend doing that as a starter project.

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • 1
    The above code works fine for whole ontology. but is there any way to handle each axioms separately ? Also how to convert the readable string to axiom so that I can update it into OWL file ? – SuhasD Jul 06 '16 at 10:18
  • 2
    `ManchesterOWLSyntaxObjectRenderer` and `ManchesterOWLSyntaxEditorParser` are the classes to use in that case. – UninformedUser Jul 06 '16 at 12:26
  • True. The parser won't deal with single axioms without a lot of setup though, as I mentioned. It's not meant for inexperienced users to just drop in their applications and use. – Ignazio Jul 06 '16 at 12:33
  • 1
    @AKSW I tried to use `ManchesterOWLSyntaxParser` to convert my readable string into axiom and `ManchesterOWLSyntaxObjectRenderer` used to represent axiom into readable string. it works thanks. – SuhasD Jul 07 '16 at 06:36