ontopuml

NIST OWL Visual Notation (NOWL)

Standard plantUML library for visualising ontology and OWL 2.0 in a standardised visual notation.

NOWL Generator

A command-line tool for converting RDF/OWL ontology files into PlantUML diagrams. The tool supports two main diagram types:

Repository structure

Documentation

Visual notations for OWL 2.0 syntax and plantUML commands can be found here.

For quick diagramming, see class-relation and object diagramming instructions here.

For detailed instruction on diagramming complex class relation diagrams (with complex axioms), see here.

NOWL diagram generator (Command line program)

NOWL diagram generator is a Python tool that converts ontology data (RDF) to PlantUML diagram. The tool uses NetworkX to calculate optimal layouts for the diagrams and can visualize the graph structure before generating PlantUML code.

Features

Requirements

Platform-Specific Setup

Windows

# Create a new environment
conda create -n nowlgen python=3.10
conda activate nowlgen

# Install pip if not already present
conda install pip -y

# Install project requirements
pip install -r nowlgen/requirements.txt

# (Optional) For enhanced interactive features, install pyreadline3
pip install pyreadline3

Build executable:

cd nowlgen
python build.py

Run the executable:

dist\nowl.exe

macOS / Linux

# Create a new environment with conda
conda create -n nowlgen python=3.10
conda activate nowlgen

# Install project requirements
pip install -r nowlgen/requirements.txt

Build executable:

cd nowlgen
python build.py

Run the executable:

# Run in interactive mode
./dist/nowl

# Run with command-line options
./dist/nowl -f ontology.owl

Cross-Platform Path Handling

The tool automatically handles path separators across platforms:

Examples that work on all platforms:

# Windows
nowl -f C:\Users\myuser\ontology.owl --nowl-profile ~/.nowl/nowl.iuml

# macOS/Linux
./nowl -f ~/Documents/ontology.owl --nowl-profile ~/.nowl/nowl.iuml

# Cross-platform (forward slashes work everywhere)
nowl -f path/to/ontology.owl --nowl-profile path/to/nowl.iuml

Command Line Options

Simple Interactive Commands

Keyboard shortcut

Available Flags

Axiom Types:

Layout algorithm spring, circular, kamada_kawai, spectral, shell, planar, random, bipartite, multipartite, u, d, l,r (last four options are for making every edge direct up, down, left, or roght respectively)

Basic usage

The output puml file will be saved at current working directory. See detailed tutorial here.

# Basic usage - generates object diagram from ontology file
# For stand-alone execuatatble 
./nowl -f ontology.rdf

# Auto-detect ontology file in current directory
./nowl

# Generate class diagram instead of object diagram
./nowl -f ontology.rdf -c

# Specify layout
./nowl -f ontology.rdf -l circular

# Specify direction
./nowl -f ontology.rdf -l u

# Include specific class
./nowl -f ontology.rdf --include-class http://example.org/Class1 -a ns

# Generate class diagram with specific axiom type
./nowl -f ontology.rdf -c -e http://example.org/Class1:ns -l u

# Generate class diagram with multiple classes and specific axiom types

./nowl -f ontology.rdf -c -e http://example.org/Class1:ns,http://example.org/Class2:ns

./nowl -f ontology.rdf --exclude-relation http://example.org/hasPart --exclude-relation http://example.org/isMadeOf

You can also run the tool directly using the included run.py script:

python run.py [OPTIONS]

This accepts all the same CLI options as the main command. For example:

# Basic usage
python run.py -f your_ontology.rdf

# Generate class diagram with specific layout
python run.py -f your_ontology.rdf -c -l bipartite

Python API

NOWL diagram generator can be used as a Python library:

Object diagram from RDF data

from generator.main import rdf_to_puml

puml_content, output_path = rdf_to_puml(
    input_rdf="path/to/ontology.owl",
    import_ontologies=["http://example.org/imported.owl"],
    layout_type="bipartite",
    visualize=False,
    save_puml=True,
    exclude_relation=["hasMetadata"],
    inline_class_declaration=True
)

Class diagram from axioms

from generator.main import axiom_to_puml

converter = axiom_to_puml(
    class_entities=[
        ("ComputingProcess", "n"),
        ("https://spec.industrialontologies.org/ontology/core/Core/Organization", "n"),
    ],
    ontology="https://spec.industrialontologies.org/ontology/core/Core",
    layout_type="u",
    save_puml=False,
)
print(converter[0])