This page provides complete practical examples showing how TSV inputs are transformed into OWL 2 ontologies using uml2semantics.
Each example illustrates:
- the TSV inputs
- expected ontology output (Manchester + Turtle)
- modelling rationale
- SHACL considerations
- typical CLI invocation
These examples form the basis for the golden tests and are designed for reproducibility.
The aligned table snippets below illustrate the schema; save actual input with tab separators. Run commands from the directory containing your TSV files and declare the prefixes used in them. SHACL validation is external to this tool.
This example demonstrates the smallest possible ontology generated from TSV inputs.
Curie Name ParentNames Definition
ex:Account Account A financial account.
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity Definition
Account Id xsd:string 1 1 Account identifier.
Class: Account
Annotations: rdfs:label "Account"
DataProperty: Id
Domain: Account
Range: xsd:string
uml2semantics -c Classes.tsv -a Attributes.tsv -o out.ttl -i http://example.org/ns --format turtle
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity MinLength MaxLength Pattern
Account OwnerId xsd:string 1 1 16 16 [A-Z0-9]+
DataProperty: OwnerId
Domain: Account
Range:
xsd:string
[ minLength 16,
maxLength 16,
pattern "[A-Z0-9]+" ]
Curie Name BaseDatatype Pattern MinLength MaxLength
iso:LEI20 LEI20 xsd:string [A-Z0-9]{20} 20 20
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity
Account LeiId LEI20 0 1
Datatype: LEI20
EquivalentTo:
xsd:string
[ pattern "[A-Z0-9]{20}",
minLength 20,
maxLength 20 ]
DataProperty: LeiId
Domain: Account
Range: LEI20
Curie Name
iso:CurrencyCode CurrencyCode
Enumeration Curie Name Definition
CurrencyCode iso:GBP GBP Pound Sterling
CurrencyCode iso:EUR EUR Euro
CurrencyCode iso:USD USD US Dollar
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity
Account Ccy CurrencyCode 1 1
Class: CurrencyCode
Individual: GBP
Types: CurrencyCode
Individual: EUR
Types: CurrencyCode
Individual: USD
Types: CurrencyCode
DataProperty: Ccy
Range: CurrencyCode
Curie Name ChoiceOf ChoiceSemantics
ex:PtyIdChoice PartyIdentifierChoice LEIId|BICId exclusive
ex:LEIId LEIId
ex:BICId BICId
Class: PartyIdentifierChoice
SubClassOf: LEIId or BICId
DisjointClasses:
PartyIdentifierChoice, LEIId
DisjointClasses:
PartyIdentifierChoice, BICId
This example shows all TSV types working together.
Curie Name ParentNames
ex:Account Account
ex:Holder Holder
ex:PtyChoice PartyChoice LEIId|BICId exclusive
Class Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity
Account Id xsd:string 1 1
Account Ccy CurrencyCode 1 1
Account Party PartyChoice 0 1
Holder Name xsd:string 1 1
Curie Name BaseDatatype Pattern MinLength MaxLength
iso:LEI20 LEI20 xsd:string [A-Z0-9]{20} 20 20
Curie Name
iso:CurrencyCode CurrencyCode
Enumeration Curie Name
CurrencyCode iso:GBP GBP
CurrencyCode iso:EUR EUR
Curie Name Definition
dct:source Source Origin of the element
TargetCurie AnnotationProperty Value
ex:Account dct:source "Imported from ISO 20022"
Class: Account
SubClassOf:
Id exactly 1 xsd:string,
Ccy exactly 1 CurrencyCode,
Party max 1 PartyChoice
Class: PartyChoice
SubClassOf: LEIId or BICId
DisjointClasses: PartyChoice, LEIId
DisjointClasses: PartyChoice, BICId
Individual: GBP
Types: CurrencyCode
graph TD
C[Classes.tsv] --> P[Parser]
A[Attributes.tsv] --> P
D[Datatypes.tsv] --> P
E[Enumerations.tsv] --> P
V[EnumerationNamedValues.tsv] --> P
AP[AnnotationProperties.tsv] --> P
AN[Annotations.tsv] --> P
P --> O[Ontology Output]
Use:
uml2semantics -c Classes.tsv -a Attributes.tsv --datatypes Datatypes.tsv --enumerations Enumerations.tsv --enum-values EnumerationNamedValues.tsv --annotation-properties AnnotationProperties.tsv --annotations Annotations.tsv -o out.ttl -i http://example.org/ns --prefixes "ex:http://example.org/ns#,dct:http://purl.org/dc/terms#" --format turtle
From the repository root, activate the virtual environment, install the CLI, and
create the output directory. If .venv does not exist yet, create it first with
python3 -m venv .venv.
source .venv/bin/activate
python -m pip install -e .
mkdir -p buildBuild an OWL ontology in RDF/XML from the ISO 20022 TSV bundle in test-tsv/:
uml2semantics \
--classes test-tsv/class.tsv \
--attributes test-tsv/attribute.tsv \
--datatypes test-tsv/datatypes.tsv \
--enumerations test-tsv/enumeration.tsv \
--enum-values test-tsv/enumerationIndividuals.tsv \
--annotation-properties test-tsv/AnnotationProperties.tsv \
--annotations test-tsv/Annotations.tsv \
--ontology-iri 'http://iso20022.org/iso20022' \
--prefixes 'iso20022=http://iso20022.org/iso20022/;iso20022dt=http://purl.org/iso20022/dt/;iso20022cd=http://purl.org/iso20022/cd/;iso20022mm=http://purl.org/iso20022/mm/' \
--format rdfxml \
--output build/iso20022.owlUse the filenames exactly as shown. The similarly named Classes.tsv,
Attributes.tsv, Enumerations.tsv, and EnumerationNamedValues.tsv are separate
files. The test-tsv/ inputs are local-only and must be supplied before running
this example.
For the same OWL ontology in Turtle, replace the final two options with:
--format turtle \
--output build/iso20022.ttlTo build the graph in memory without writing output, replace --output and its
filename with --dry-run.
- Back to TSV Specification
- Continue to Golden Tests
- Return to Home