Skip to content

Improve support for human readable IRIs #486

@jesper-friis

Description

@jesper-friis

In ontologies like EMMO, that uses numerical IDs, we want to refer to the concepts with human readable CURIEs consisting of a prefix and a label. For example, it should be possible to refer to the IRI https://w3id.org/emmo#EMMO_eb77076b_a104_42ac_a065_798b2d2809ad as "emmo:Atom".

Transformations in both directions should be possible.

This can be split into several subtasks:

  • Namespace objects include all information (except namespace prefix) needed for these transformations. Add a method for converting a full IRI to a short human readable prefixed IRI.

    Implemented in PR: Added reverse mapping to Namespace objects using the __call__() method. #483

  • Add an option to Triplestore.prefix_iri() to return human readable prefixed IRIs. Should be implemented in tripper.utils.prefix_iri(). This would require that the prefixes argument has Namespace objects as values.

  • Add an option to Triplestore.expand_iri() to accept a human readable prefixed IRI as input. Should be implemented in tripper.utils.expand_iri(). This would require that the prefixes argument has Namespace objects as values.

  • Make it possible to register namespaces that uses numerical IDs. This register should be checked when parsing prefixes (e.g. from a json-ld context, a keywords file, a dict, etc...). Add an utility function that takes a dict with prefix-namespace string pairs as input and return a dict mapping prefixes to Namespace objects as output. Namespace objects for numerical IDs should be created with the triplestore, label_annotations and check arguments set (the values should be fetch from the register). Ensure that this utility function is called whenever prefix-definitions are parsed.

    For efficiency, avoid duplicating Namespace objects that are created with the triplestore argument. This can be achieved with a cache mapping namespace IRIs to weakref's to created Namespace objects.

  • Add option to enable support for human IRIs to all code that parses IRIs and propagate it to prefix_iri()/expand_iri(). Also ensure that prefixes are specified with namespace objects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions