Chris Day's GitHub Pages

Chris Day's GitHub Pages

uml2semantics-python 0.9.31

A refactored Python implementation of the original uml2semantics tool, updated so that OWL 2 semantics are used consistently throughout the generated ontology.

This work would not be possible without Henriette Harmse’s https://henrietteharmse.com/uml-vs-owl/uml-class-diagram-to-owl-and-sroiq-reference/ and the reference implementation here https://github.com/henrietteharmse/uml2semantics

Key features

Installation

pip install .

or, using pipx:

pipx install .

Command-line usage

The main entry point is:

uml2semantics [OPTIONS]

Supported options (compatible with 0.8.2, extended):

Example:

uml2semantics -i examples/simple-model.xmi -o examples/simple-model.owl -f turtle -p iso20022

Python API

from uml2semantics.ontology_builder import build_ontology
from uml2semantics.tsv_loader import load_model

model = load_model(
    classes_tsv="examples/Classes.tsv",
    attributes_tsv="examples/Attributes.tsv",
    datatypes_tsv="examples/Datatypes.tsv",
    enums_tsv="examples/Enumerations.tsv",
    enum_literals_tsv="examples/EnumerationNamedValues.tsv",
    annotation_properties_tsv="examples/AnnotationProperties.tsv",
    annotations_tsv="examples/Annotations.tsv",
)

g = build_ontology(
    model,
    ontology_iri="http://example.org/uml2semantics/demo#",
    prefix_str="ex=http://example.org/;rdfs=http://www.w3.org/2000/01/rdf-schema#;dct=http://purl.org/dc/terms/;xsd=http://www.w3.org/2001/XMLSchema#",
)
g.serialize("examples/demo.ttl", format="turtle")

Annotation TSVs

Choice semantics

Datatypes

See docs/cli.md and docs/architecture.md for more details.