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 ontobuilder.

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

ontobuilder init "Hospital Booking"
ontobuilder concept add Patient --description "A person receiving care"
ontobuilder concept add Surgeon
ontobuilder concept add SurgeryBooking
ontobuilder relation add assigned_surgeon --from SurgeryBooking --to Surgeon
ontobuilder info
ontobuilder owl export --format turtle
ontobuilder owl reason
ontobuilder owl query describe SurgeryBooking

Build From Data

ontobuilder tool analyze data.csv
ontobuilder tool suggest data.csv
ontobuilder tool build data.csv
ontobuilder 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:

ontobuilder configure

Then you can use:

ontobuilder interview
ontobuilder infer data.csv            # AI-powered
ontobuilder infer data.csv --local    # offline, no API key; launches interactive review
ontobuilder 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
ontobuilder init Create a new ontology file in the current directory
ontobuilder info Show summary information about the current ontology
ontobuilder concept add/list/remove Manage concepts
ontobuilder relation add/list/remove Manage relations
ontobuilder save / ontobuilder load Save or load .onto.yaml files
ontobuilder export Export to yaml, json, prompt, jsonld, schema-card, owl, or turtle
ontobuilder owl export Export OWL as RDF/XML or Turtle
ontobuilder owl reason Run inference and consistency checks
ontobuilder owl query Query classes, instances, relations, descriptions, validation, or paths
ontobuilder tool analyze Inspect a data file
ontobuilder tool suggest Generate ontology suggestions from data
ontobuilder tool build Build an ontology from data
ontobuilder suggest Suggest likely next steps for the current ontology
ontobuilder learn Show glossary-style explanations of ontology terms
ontobuilder domains list/apply List and apply built-in domain templates
ontobuilder configure Configure an LLM provider
ontobuilder interview Build an ontology through an AI-assisted interview
ontobuilder infer Infer an ontology draft from a data file (use --local for offline interactive review)
ontobuilder chat Ask questions about the current ontology
ontobuilder 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
ontobuilder 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.7.tar.gz (150.8 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.7-py3-none-any.whl (90.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ontobuilder-0.1.7.tar.gz
  • Upload date:
  • Size: 150.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ontobuilder-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c60ed5580e923ca82cd98e866befb4c5ec6fed3338493a1d22cfdd5a457c5f98
MD5 c4f119c558cf41e8860681b850625b58
BLAKE2b-256 3162bac11dd6228f2388d7c0e96dbe08e15be687c6ac1fec21bb175fc935afc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ontobuilder-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 90.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ontobuilder-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 61b967ab518410125f15108571317ac266181fd19ee3f417ae28382ca5b4e8eb
MD5 db8c30609606ef251516dde76ebc9fd3
BLAKE2b-256 fa9d311686565b086156c9b6ef5f817c9ef9bc461e41052ca59f08706dc6fc3e

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