Git Product home page Git Product logo

uml2semantics's Introduction

uml2semantics is an application that allows you to convert a UML class diagram to an OWL 2 ontology. Translating a UML class diagram to an OWL 2 ontology allows one to reason over the ontology and thereby discover possible inconsistencies or unintended consequences. The UML to OWL translation we use is based on UML to OWL, which provides the related Manchester syntax and SROIQ semantics.

Project status

uml2semantics is in the very early stages of development and thus is missing many features. Currently it has support for specifying classes and attributes/associations using TSV files.

Assumption

This tool assumes that the UML class diagrams are conceptual models and as such they contain no implementation related details like interfaces, access modifiers or operations.

Downloading

Download uml2semantics.jar from latest release.

Quick Start

Employer and Employee example

As a quick start here is a small UML class diagram that we will convert to OWL. We define a Person class that has attributes name, surname and dateOfBirth. The types we use are name and surname is xsd:string and for dateOfBirth we use xsd:dateTime. Employee and Employer extends Person. An employee has exactly 1 employer and an employer has 1 or more employees.

Employer Example

TSV representation

UML class diagram information can be specified using TSV files. First create the TSV file for your classes. It has the following format:

Curie Name Definition ParentNames
Person
Employee Person
Employer Person

Here we only specify the name for each class, hence the reason we used the Name column to define our classes. Since Employee and Employer both extend the Person class, we add Person to ParentNames column. Multiple parents are separated by |. Curie refer to compact URI based on the W3C CURIE syntax.

If you want to make use of enumerations, specify them next. The format is as follows:

Curie Name Definition
emp:SalarySchedule PaymentSchedule Defines the frequency of payments

Again you can specify a curie and/or a name to refer to your enumeration. In this case we assume there is a difference between the purl and the label of this concept. Definition allows you to describe this enumeration.

The values that an enumeration exists of, are specified in a different TSV with the following format:

Enumeration Curie Name Definition
emp:SalarySchedule emp:Daily Employee gets paid at the end of each day
PaymentSchedule Weekly Employee gets paid at the end of each week on a Friday
emp:SalarySchedule emp:Monthly Employee gets paid at the last day of the month

** Enumeration ** refers the name or curie of an enumeration. Each value of an enumeration can have a curie and/or a name and a definition.

To specify attributes we use the following format.

Class Curie Name ClassOrPrimitive MinMultiplicity MaxMultiplicity Definition
Person name xsd:string
Person surname xsd:string
Person dateOfBirth xsd:dateTime
Employee employedBy Employer 1 1
Employer employes Employee 1 *

Class refers to the class for which we are defining the attributes. Attributes can also be defined using curies, but we again only used names for now. The type of an attribute can be a primitive or a class. Currenlty XML primitive data types used in Protege Desktop as data types are supported. When no multiplicity is given, [1..1] is assumed. * is to refer to infinite as per usual.

A Google spreadsheet for this UML class diagram can be found here. Save the classes and attributes tabs as TSV files.

Run uml2semantics

Assuming you have download uml2semantics to a$uml2semantics directory and saved the .tsv files to this directory as well, you can run it as follows:


java -jar uml2semantics.jar \ 
-c "$uml2semantics/Employer - Classes.tsv" \
-a "$uml2semantics/Employer - Attributes.tsv" \
-e "$uml2semantics/Employer - Enumerations.tsv" \
-n "$uml2semantics/Employer - EnumerationNamedValues.tsv" \
-o "$uml2semantics/employer.rdf" \
-p "emp:http://uml2semantics.org/examples/employer#" \
-i "http://uml2semantics.org/examples/employer/v.0.1" 

This will cause the ontology to be written out to $uml2semantics/employer.owl. An example of this file can be seen here

DCAT version 2 Example

Initial DCAT version 2 example is defined here.

uml2semantics's People

Contributors

henrietteharmse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mandixbw

uml2semantics's Issues

UML classes with equally named attributes

Hello Henriette,

I'm trying to generate either LinkML schemas or OWL ontologies from a UML model from Sparx Enterprise Architect. For the sake of simplicity (and without loss of generality) I'll assume I'mg going to generate OWL.

First of all thank you for your UML Class Diagram to OWL and SROIQ Reference, which is really helpful!

One fundamental issue I've come across that doesn't seem to be covered by that reference though is how to map class attributes onto OWL datatype properties. It seems trivial, but it gets tricky when you consider multiple classes with an equally named attribute.

For example, say you have a Person class with an attribute name, and a class Company also with an attribute name. In UML, these attributes cannot be assumed to be identical, and following the Closed World Assumption can therefore be said to be different. Mapping such attributes to OWL properties should be done with caution, especially because of the inference semantics and first-class citizenship of properties.

I see two possible ways forward to map UML attributes to OWL datatype properties:

  1. Respect the fact that equal names don't imply equal identity, and make sure you generate distinct datatype properties for each occurrence of an attribute, despite equal names. To resolve the name clashes, you could prefix the resulting property name with the class name. In the example this would yield (for example) :Person.name with domain :Person and :Company.name with domain :Company. This feels like the most safe and correct mapping, but it's also very ugly.
  2. Create a datatype property :name and have its domain be equal to the most general superset of all classes. This is well-defined because in the worst case there's always owl:Thing or rdfs:Resource (I'd have to refresh my theory here). Although this looks nicer, it does make assumptions you cannot ground, namely that equally named attributes across classes are identical, something (as we saw) that's not the case in the original UML.

Honestly, I cannot justify 2 from a semantic perspective. 1, on the other hand, tells me OWL simply isn't the right target metamodel for having my UML expressed in. Please note that the underlying problem I'm trying to solve is to export the UML model from Enterprise Architect to a human and machine readable code representation that supports Linked Data (URIs).

I really struggle with this. How would you go about it? Really curious to hear your thoughts.

Thanks!

PS This question may touch on #4, but it's a different question ultimately.

Add opaque name example

In all the examples this far I have used names as typically used in UML class diagrams. However, in proper ontologies, opaque names are common and often preferred. Ideally I should make this clear through a proper example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.