Search code examples
javaowl-apidescription-logic

DL expression generation using OWL API


I need to generate DL expression from OWLObject in OWL API. For now, I am using DLSyntaxObjectRenderer like:

DLSyntaxObjectRenderer obj = new DLSyntaxObjectRenderer();

The problem is that the DL expressions that are generated only contain the labels of the resources (e.g. Awning ⊔ Door ⊔ Gate ⊔ Shutter ⊔ Window). While these are syntactically valid DL expressions, for implementation sake, I need the IRIs of the atomic entities so that I can load the expression using OWL API after without having to load the entire ontology.

How can I achieve this ?


Solution

  • The ShortFormProvider determines the rendering of entities. It has several implementation such as ManchesterOWLSyntaxPrefixNameShortFormProvider, QNameShortFormProvider, SimpleShortFormProvider. For example, the following code use the DLSyntaxObjectRenderer and make it render DL expressions using the IRI of entities,

    obj = new DLSyntaxObjectRenderer();
    ShortFormProvider shortFormProvider = new ShortFormProvider() {
                    @Override
                    public String getShortForm(OWLEntity owlEntity) {
                        return owlEntity.getIRI().getIRIString();
                    }
                };
    obj.setShortFormProvider(shortFormProvider);
    

    To render an expression exp, simply use obj.render(exp)