owlapy.render

Renderers for different syntax.

Attributes

mapper

DLrenderer

ManchesterRenderer

Classes

DLSyntaxObjectRenderer

DL Syntax renderer for OWL Objects.

ManchesterOWLSyntaxOWLObjectRenderer

Manchester Syntax renderer for OWL Objects

Functions

translating_short_form_provider(→ str)

e: entity.

translating_short_form_endpoint(→ str)

Translates an OWLEntity to a short form string using provided rules and an endpoint.

owl_expression_to_dl(→ str)

owl_expression_to_manchester(→ str)

Module Contents

owlapy.render.mapper
owlapy.render.translating_short_form_provider(e: owlapy.owl_object.OWLEntity, reasoner, rules: dict[str:str] = None) str[source]

e: entity. reasoner: OWLReasoner or Triplestore(from Ontolearn) rules: A mapping from OWLEntity to predicates,

Keys in rules can be general or specific iris, e.g., IRI to IRI s.t. the second IRI must be a predicate leading to literal

owlapy.render.translating_short_form_endpoint(e: owlapy.owl_object.OWLEntity, endpoint: str, rules: dict[abc.ABCMeta:str] = None) str[source]

Translates an OWLEntity to a short form string using provided rules and an endpoint.

Parameters: e (OWLEntity): The OWL entity to be translated. endpoint (str): The endpoint of a triple store to query against. rules (dict[abc.ABCMeta:str], optional): A dictionary mapping OWL classes to string IRIs leading to a literal.

Returns: str: The translated short form of the OWL entity. If no matching rules are found, a simple short form is returned.

This function iterates over the provided rules to check if the given OWL entity is an instance of any specified class. If a match is found, it constructs a SPARQL query to retrieve the literal value associated with the entity and predicate. If a literal is found, it is returned as the short form. If no literals are found, the SPARQL query and entity information are printed for debugging purposes. If no matching rules are found, a warning is issued and a simple short form is returned.

Example: >>> e = OWLEntity(”http://example.org/entity”) >>> endpoint = “http://example.org/sparql” >>> rules = {SomeOWLClass: “http://example.org/predicate”} >>> translating_short_form_endpoint(e, endpoint, rules)

class owlapy.render.DLSyntaxObjectRenderer(short_form_provider: Callable[[owlapy.owl_object.OWLEntity], str] = _simple_short_form_provider)[source]

Bases: owlapy.owl_object.OWLObjectRenderer

DL Syntax renderer for OWL Objects.

__slots__ = '_sfp'
set_short_form_provider(short_form_provider: Callable[[owlapy.owl_object.OWLEntity], str]) None[source]

Configure a short form provider that shortens the OWL objects during rendering.

Parameters:

short_form_provider – Short form provider.

render(o: owlapy.owl_object.OWLObject) str[source]

Render OWL Object to string.

Parameters:

o – OWL Object.

Returns:

String rendition of OWL object.

class owlapy.render.ManchesterOWLSyntaxOWLObjectRenderer(short_form_provider: Callable[[owlapy.owl_object.OWLEntity], str] = _simple_short_form_provider, no_render_thing=False)[source]

Bases: owlapy.owl_object.OWLObjectRenderer

Manchester Syntax renderer for OWL Objects

__slots__ = ('_sfp', '_no_render_thing')
set_short_form_provider(short_form_provider: Callable[[owlapy.owl_object.OWLEntity], str]) None[source]

Configure a short form provider that shortens the OWL objects during rendering.

Parameters:

short_form_provider – Short form provider.

render(o: owlapy.owl_object.OWLObject) str[source]

Render OWL Object to string.

Parameters:

o – OWL Object.

Returns:

String rendition of OWL object.

owlapy.render.DLrenderer
owlapy.render.ManchesterRenderer
owlapy.render.owl_expression_to_dl(o: owlapy.owl_object.OWLObject) str[source]
owlapy.render.owl_expression_to_manchester(o: owlapy.owl_object.OWLObject) str[source]