SuhasD
SuhasD

Reputation: 738

How protege shows OWL axioms in readable format

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)

Upvotes: 0

Views: 351

Answers (1)

Ignazio
Ignazio

Reputation: 10659

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.

Upvotes: 3

Related Questions