This is an environment to design ontologies.
- Python 66.3%
- Rust 33.7%
Rust (oxigraph + PyO3) parses Turtle and extracts OWL classes, object properties, datatype properties, and subclass hierarchies. Python computes Graphviz layout and generates Gaphor XML with auto-positioned diagram items. |
||
|---|---|---|
| python/ontocraft | ||
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.toml | ||
| contributors.ttl | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
ontocraft
Generate Gaphor UML diagrams from OWL/RDF ontologies (Turtle format).
ontocraft parses OWL ontology files, extracts the class hierarchy, object properties, and datatype properties, computes a Graphviz layout, and writes a .gaphor file you can open and edit in Gaphor.
Architecture
- Rust (via oxigraph): parses Turtle, runs SPARQL queries to extract ontological structure
- Python (via PyO3 + Maturin): computes layout with PyGraphviz, generates Gaphor XML
Installation
Requires Rust toolchain, Python 3.9+, and the Graphviz development libraries.
# Install system dependency (Debian/Ubuntu)
sudo apt install libgraphviz-dev
# Build and install in a virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install maturin pygraphviz
maturin develop
Usage
ontocraft ontology.ttl -o diagram.gaphor
If -o is omitted, the output file defaults to <input>.gaphor.
Supported OWL constructs
owl:Classwithrdfs:labelrdfs:subClassOfhierarchiesowl:ObjectPropertywithrdfs:domain/rdfs:rangeowl:DatatypePropertywithrdfs:domain/rdfs:range
Running tests
pip install pytest
python -m pytest tests/ -v
License
MIT