Skip to main content

Build, explore, and export ontologies from data — no PhD required.

Project description

OntoBuilder

Build small, understandable ontologies from scratch or from data, then inspect, refine, and export them without needing to know OWL up front.

OntoBuilder is a Python toolkit for creating ontologies with concepts, properties, relations, and instances. It ships with a CLI, a Python API, OWL/RDF export, lightweight reasoning, data-to-ontology helpers, optional AI-assisted workflows, and a Streamlit app for visual editing.

What To Expect

  • Good fit for: learning ontology modeling, prototyping domain models, turning CSV/JSON structure into a first ontology draft, exporting to OWL/Turtle/JSON-LD, and iterating from the terminal or Python.
  • Core workflows work locally: create an ontology, edit it, save it as .onto.yaml, inspect it, export it, and run basic reasoning checks.
  • AI features are optional: interview mode, inference from sample data, and the live workspace need LLM dependencies and provider setup.
  • The project is still early-stage: useful already, but expect some rough edges around advanced flows and docs.

Main Ways To Use It

1. CLI

The installed command is onto.

If you prefer, you can also run the module form:

python -m ontobuilder

Use the CLI when you want to:

  • create and save an ontology project
  • add concepts, relations, and properties from the terminal
  • export to YAML, JSON, prompt text, JSON-LD, Schema Card, OWL, or Turtle
  • run reasoning and structured queries
  • build from data or use the AI-assisted workspace

2. Python API

Use the Python API when you want to script ontology creation directly inside your application or notebook.

3. Streamlit App

Use the web UI when you want a more visual editing flow with graph views and guided next steps.

Installation

# Core package
pip install ontobuilder

# AI-assisted features
pip install ontobuilder[llm]

# Streamlit app
pip install ontobuilder[web]

# Everything
pip install ontobuilder[all]

For local development:

git clone https://github.com/iksun/ontobuilder.git
cd ontobuilder
pip install -e ".[dev,llm,web]"

Quick Start

Python API

from ontobuilder import Ontology

onto = Ontology("Pet Store", description="A simple pet store ontology")

onto.add_concept("Animal", description="A living creature")
onto.add_concept("Dog", parent="Animal", description="A domestic dog")
onto.add_concept("Customer", description="A person who buys pets")

onto.add_property("Animal", "name", data_type="string", required=True)
onto.add_property("Dog", "breed", data_type="string")

onto.add_relation("buys", source="Customer", target="Animal")

onto.add_instance("Rex", concept="Dog", properties={"name": "Rex", "breed": "Labrador"})

print(onto.print_tree())

CLI Basics

# The CLI command is `onto`
onto init "Hospital Booking"
onto concept add Patient --description "A person receiving care"
onto concept add Surgeon
onto concept add SurgeryBooking
onto relation add assigned_surgeon --source SurgeryBooking --target Surgeon
onto info
onto owl export --format turtle
onto owl reason
onto owl query describe SurgeryBooking

Build From Data

onto tool analyze data.csv
onto tool suggest data.csv
onto tool build data.csv
onto tool build -i data.csv

What this flow gives you:

  • analyze shows the structure OntoBuilder sees in the file
  • suggest proposes concepts and relations
  • build creates an ontology draft
  • build -i lets you review suggestions step by step

AI-Assisted Workflows

First configure an LLM provider:

onto configure

Then you can use:

onto interview
onto infer data.csv
onto workspace data.csv

Use these when you want:

  • interview - guided ontology design through questions
  • infer - a quick AI-generated ontology draft from data
  • workspace - data -> ontology draft -> chat refinement -> OWL export

Web UI

pip install ontobuilder[web]
streamlit run streamlit_app.py

The app includes concept editing, graph visualization, CSV-assisted ontology building, next-step suggestions, and chat-based exploration.

CLI Command Map

Command What it does
onto init Create a new ontology file in the current directory
onto info Show summary information about the current ontology
onto concept add/list/remove Manage concepts
onto relation add/list/remove Manage relations
onto save / onto load Save or load .onto.yaml files
onto export Export to yaml, json, prompt, jsonld, schema-card, owl, or turtle
onto owl export Export OWL as RDF/XML or Turtle
onto owl reason Run inference and consistency checks
onto owl query Query classes, instances, relations, descriptions, validation, or paths
onto tool analyze Inspect a data file
onto tool suggest Generate ontology suggestions from data
onto tool build Build an ontology from data
onto suggest Suggest likely next steps for the current ontology
onto learn Show glossary-style explanations of ontology terms
onto domains list/apply List and apply built-in domain templates
onto configure Configure an LLM provider
onto interview Build an ontology through an AI-assisted interview
onto infer Infer an ontology draft from a data file
onto chat Ask questions about the current ontology
onto workspace Open a live AI-assisted ontology workspace

Files You Will See

  • ontology.onto.yaml - the default working ontology file used by the CLI
  • ontology.ttl / ontology.owl - common export outputs
  • your source CSV/JSON files - optional inputs for data-assisted modeling

Architecture At A Glance

src/ontobuilder/
|- core/           # Ontology model, concepts, properties, relations, validation
|- cli/            # Typer-based CLI
|- serialization/  # YAML, JSON, JSON-LD, Schema Card, prompt export
|- owl/            # OWL/Turtle export, reasoning, structured query support
|- llm/            # Optional LLM-backed inference and interview flows
|- chat/           # Ontology chat and workspace flows
|- tool/           # Data analysis and ontology suggestion pipeline
|- graph/          # NetworkX and optional Neo4j utilities
|- domains/        # Built-in domain templates
`- education/      # Beginner glossary and learning helpers

Examples

See the examples/ directory for starter files and datasets.

Useful starting points:

  • examples/quickstart.py - basic Python API walkthrough
  • examples/hospital_surgery_booking.onto.yaml - example ontology file
  • examples/hospital_surgery_bookings.csv - sample input dataset
  • examples/real_ecommerce_orders.csv - e-commerce-style dataset

Example commands:

python examples/quickstart.py
onto tool build -i examples/hospital_surgery_bookings.csv

Running Tests

pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ontobuilder-0.1.2.tar.gz (138.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ontobuilder-0.1.2-py3-none-any.whl (81.0 kB view details)

Uploaded Python 3

File details

Details for the file ontobuilder-0.1.2.tar.gz.

File metadata

  • Download URL: ontobuilder-0.1.2.tar.gz
  • Upload date:
  • Size: 138.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontobuilder-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4afb0e708f4307548091995149ee93f7e5827e3c2258f32996da69ab52e44fdc
MD5 740df4a771bfaf0cbe5289049201fe91
BLAKE2b-256 9fffd3ed21d6cee2ff492c914d4cd41be8bc213f50d6689ad19ed28188d36831

See more details on using hashes here.

File details

Details for the file ontobuilder-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ontobuilder-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 81.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ontobuilder-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9d3926a9faeb8da372ec12ce9f2643067b052a58fac1049a5b074aef8832f6
MD5 56fa170d1fab891735c969bea9017a4f
BLAKE2b-256 80e491ffc29f9828442d8cb5b626f961ed9ba2556fe2bf08dca6830f2fffee03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page