Annabelle
Annabelle

Reputation: 754

OWL API axioms with short prefixes

OWL API in Java offers working with set of axioms through:

domainOntology.getAxioms()

All axioms have long prefixes by default, e.g.:

ObjectPropertyAssertion(<http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#locatedIn> <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#TexasRegion> <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#USRegion>) 

How can I transform the axioms to axioms with short prefixes, e.g:

ObjectPropertyAssertion( wine:locatedIn wine:TexasRegion wine:USRegion )

Ontology can of course have more prefixes defined (not only e.g. "wine")

Upvotes: 1

Views: 324

Answers (2)

Ignazio
Ignazio

Reputation: 10659

What you're seeing is the toString() value; that's for debugging purposes, not for further processing.

Depending on what exactly you wish to achieve, you might be better off picking a language that supports prefixes (e.g., Manchester OWL Syntax or Functional Syntax), set the prefixes you wish yo use and render the axioms:

FunctionalSyntaxDocumentFormat format=new FunctionalSyntaxDocumentFormat();
format.setPrefix("ont", "http://test.com/ontology");
ontology.saveOntology(format, System.out);

Upvotes: 1

andrea-f
andrea-f

Reputation: 1055

You need to use a prefix, take for example the following SPARQL query:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select * where {
SERVICE <http://it.dbpedia.org/sparql/> {
    SELECT * where {
       ?value rdfs:label "Personaggi dei fumetti"@it .
       ?title <http://purl.org/dc/terms/subject> ?value . 
       OPTIONAL {?title <http://dbpedia.org/ontology/firstAppearance> ?start_date .   
   }
       OPTIONAL {?title <http://dbpedia.org/ontology/author> ?author . }
       OPTIONAL {?title <http://it.dbpedia.org/property/paese> ?country .} 
       OPTIONAL {?title <http://it.dbpedia.org/property/sesso> ?gender .}  
       OPTIONAL {?title <http://it.dbpedia.org/property/dataInizio> ?date .}
   }
}
}

Using the PREFIX keyword when setting up the query allows you to use the prefixed word as a substitution for the URL that it relates to.

Upvotes: 0

Related Questions