Skip to main content

Python bindings for the OntoLogos OWL reasoner — RDFS, OWL RL, and OWL EL classification

Project description

ontologos

PyPI Python Documentation License

Python bindings for OntoLogos — a Rust-native OWL reasoner for RDFS, OWL RL, and OWL EL classification.

Load .owl / .ttl files or build ontologies in memory, run the same profile engines as the CLI, and export taxonomies to pandas or Polars. Powered by PyO3 and the stable Python ABI (abi3).

Full guide: ontologos.readthedocs.io — Python

Features

  • File or in-memoryReasoner(path=...) or Ontology / OntologyBuilder
  • Profiles"rdfs", "rl", "el", or "auto" (detects EL vs RL)
  • Classify — RDFS/RL materialization reports or EL taxonomy dicts
  • Explain — proof graph dicts with IRI-resolved conclusions (EL full traces)
  • Incremental — multi-pass add_subclass_of / remove_subclass_of with incremental=True
  • Export — optional subsumptions_to_pandas / subsumptions_to_polars

Install

Requires Python 3.10+.

pip install ontologos

Optional DataFrame helpers:

pip install 'ontologos[pandas]'
pip install 'ontologos[polars]'

Pre-built wheels are published for:

OS Architectures
Linux x86_64, aarch64 (manylinux)
macOS x86_64, aarch64
Windows x64, aarch64

One abi3 wheel per platform covers Python 3.10–3.13+. If no wheel matches, build from source (Rust + maturin).

Quick start

Classify an OWL file

import ontologos

# OWL EL taxonomy
reasoner = ontologos.Reasoner(path="pizza.owl", profile="el")
taxonomy = reasoner.classify()
print(taxonomy["subsumption_count"], taxonomy["subsumptions"][:3])

# RDFS materialization
reasoner = ontologos.Reasoner(path="ontology.owl", profile="rdfs")
report = reasoner.classify()
print(report["inferred_axioms"])

# Auto-detect profile (EL or RL)
reasoner = ontologos.Reasoner(path="ontology.owl", profile="auto")
result = reasoner.classify()

Build in memory

from ontologos import OntologyBuilder, Reasoner

builder = OntologyBuilder()
builder.add_class("http://example.org/A")
builder.add_class("http://example.org/B")
builder.subclass_of("http://example.org/A", "http://example.org/B")
ontology = builder.build()

reasoner = Reasoner(ontology=ontology, profile="el")
taxonomy = reasoner.classify()

Load from JSON v2 dict instead of the builder:

from ontologos import Ontology, Reasoner

ontology = Ontology.from_dict({
    "format_version": 2,
    "entities": [
        {"iri": "http://example.org/A", "kind": "Class"},
        {"iri": "http://example.org/B", "kind": "Class"},
    ],
    "axioms": [
        {"SubClassOf": {
            "subclass": "http://example.org/A",
            "superclass": "http://example.org/B",
        }}
    ],
})
reasoner = Reasoner(ontology=ontology, profile="el")
reasoner.classify()

Incremental edits

reasoner = Reasoner(ontology=ontology, profile="el", incremental=True)
reasoner.classify()

reasoner.add_subclass_of("http://example.org/B", "http://example.org/C")
reasoner.classify()  # re-classify with warm session

reasoner.remove_subclass_of("http://example.org/A", "http://example.org/B")
reasoner.classify()

Explain inferences

graph = reasoner.explain()
print(graph["node_count"])
for node in graph["nodes"][:5]:
    print(node["rule"], node.get("conclusion_sub"))
Profile Explain coverage
EL Full inference traces
RL / RDFS Asserted axioms seeded; inferred steps lack per-rule premises until upstream exposes traces
auto Routes like classify

Export to DataFrame

from ontologos import subsumptions_to_pandas

df = subsumptions_to_pandas(taxonomy)
# columns: subclass, superclass

API overview

Type / method Description
Reasoner(path=..., profile=..., incremental=False) Load OWL file and classify
Reasoner(ontology=..., ...) Classify in-memory ontology
reasoner.classify() Run engine; returns taxonomy or materialization dict
reasoner.explain() Proof graph dict (node_count, nodes, parse_meta)
reasoner.taxonomy Last EL taxonomy (after classify)
reasoner.parse_meta Parser warnings and axiom counts
reasoner.add_subclass_of / remove_subclass_of Incremental axiom edits
reasoner.add_axiom_json Add axiom via JSON v2 object
Ontology.from_json / from_dict Load JSON v2 snapshot
OntologyBuilder Fluent builder → build()
subsumptions_to_pandas / subsumptions_to_polars Optional taxonomy export

Invalid profiles and unsupported constructs raise RuntimeError with a message string.

Reasoner is not thread-safe — do not mutate from multiple threads.

Development

From a repository clone:

cd crates/ontologos-py
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install 'maturin>=1.7,<2.0' pytest '.[pandas]'
maturin develop --release
pytest tests/ -q

Pizza EL golden test (requires corpus):

./benchmarks/scripts/download.sh   # from repo root
pytest tests/test_pizza_golden.py -q

What OntoLogos is (and is not)

OntoLogos is an orchestration layer: profile detection, a unified ontology model, CLI, Python wheels, and security limits on top of in-house EL and reasonable for RL/RDFS. It maps a subset of OWL — not full OWL DL / HermiT replacement.

For engine-only workflows, consider reasonable, whelk-rs, or horned-owl directly.

Links

Resource URL
Python guide readthedocs — Python
Getting started readthedocs
Migration v0.8 → v0.9 migration guide
Repository github.com/eddiethedean/ontologos
Rust crates crates.io — ontologos-core
Changelog CHANGELOG.md

License

Licensed under either of Apache-2.0 or 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

ontologos-0.9.0.tar.gz (121.4 kB view details)

Uploaded Source

Built Distributions

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

ontologos-0.9.0-cp310-abi3-win_arm64.whl (1.4 MB view details)

Uploaded CPython 3.10+Windows ARM64

ontologos-0.9.0-cp310-abi3-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.10+Windows x86-64

ontologos-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

ontologos-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

ontologos-0.9.0-cp310-abi3-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

ontologos-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file ontologos-0.9.0.tar.gz.

File metadata

  • Download URL: ontologos-0.9.0.tar.gz
  • Upload date:
  • Size: 121.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.0

File hashes

Hashes for ontologos-0.9.0.tar.gz
Algorithm Hash digest
SHA256 35fcbb01c2f09c0b0d79df8eee24efa6149ab18f586fde4da79cb186aa5b4716
MD5 84e19db0f2957f368f3d237b6ecfc938
BLAKE2b-256 3ab3fdb0c6acb6eb931c659d47cf2b8a66c4747e32eb5d6e12bd2abecf6197da

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 f9e2ba51a2c67b6efbcee2bf4642e7c7c5f88954538623d1659541137162eb90
MD5 47c2139bb7a1c127708047f04c28ed56
BLAKE2b-256 e7f8ca006a4bc52aebb7d4c51d214ef6e35402e3871f77db6d0b7c3cf625b84e

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cf1c1e09ceca6ae248edf516716a96703db53c19b890ad0f2d20a011bb0967b8
MD5 6c537c8198c42b668a87a17d042c13d0
BLAKE2b-256 5334a0376084c461aedfa21f2de92fc19b464cd93f830d5ef7e8546cfcc4c922

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dcd50e4468eb7a3733d725a3f690be896960e9633e8e63b08a70161557ba2d58
MD5 b6f9b3211d694a61f47f4ae9da63fd3a
BLAKE2b-256 94b6ccaf779baaeb26d20e204b4ef7c57974e7994a6eb2d975a6776f7aafb775

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2b14e6c56b865320620599dd614892592291ed365ffdfdd151f98cb7f84659c1
MD5 daebd63605cab37ce0dcbe2546c76c2e
BLAKE2b-256 24261e4697ab7cdd13cfdd7fab993c4d2c8a294c47db61ac865ca07505a6ee16

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e94fdd70b3ed47848becd3bce4eec9561ee1d30929848d18c689df179110abe6
MD5 14a0a789383e8c5b55265a4bda04f220
BLAKE2b-256 87b12fa595d4027b6b49a3149f37af94c35ebb67bdbf45861679f39326846ef4

See more details on using hashes here.

File details

Details for the file ontologos-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ontologos-0.9.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a9f37f0a55e72506d9ff5a34ff599fb98f4c8a4e8786865210884fac06366203
MD5 0d27b2f423527268c652f6a1df9cb9dd
BLAKE2b-256 417dcbd6ee3e19861d9250f822e3bffc15ae5fd8dd9d468744e937a65a813d6b

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