Metadata-Version: 2.5
Name: ontology-quality-suite
Version: 0.3.5
Summary: Ontology Quality Suite -- assess OWL2 DL/RL/QL ontologies, TARQL/oxi-gen CONSTRUCT-query sketches, and the RDF data graphs they triplify -- structural, logical, documentation, efficiency, style, data quality, OWL2 profile membership, and reasoner-based consistency -- plus ontology-version and TARQL/ontology consistency checking with suggested repair diffs, locally or against a live Fuseki triplestore.
Project-URL: Repository, https://github.com/pwin/consolidated-ontology-quality-suite-python
Project-URL: Issues, https://github.com/pwin/consolidated-ontology-quality-suite-python/issues
Author-email: pwin <pw@inbox.lv>
License-Expression: MIT OR Apache-2.0
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Keywords: linked-data,ontology,owl,rdf,semantic-web,shacl,sparql,tarql
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Requires-Dist: matplotlib>=3.7.0
Requires-Dist: owlready2>=0.51
Requires-Dist: owlrl>=6.0.2
Requires-Dist: pandas>=2.0.0
Requires-Dist: pyshacl>=0.25.0
Requires-Dist: rdflib>=7.6.0
Requires-Dist: tabulate>=0.9.0
Provides-Extra: reasoner
Requires-Dist: owlready2>=0.47; extra == 'reasoner'
Description-Content-Type: text/markdown

# Ontology Quality Suite

Python tools for checking that an OWL2 ontology stays internally consistent
across versions, and that TARQL/oxi-gen CONSTRUCT-query transformation files
stay aligned with the ontology(ies) they triplify against -- namespaces,
class/property usage -- with **suggested diffs for automated repair**,
either against local files or a live Fuseki (SPARQL 1.1 Protocol)
triplestore.

This package carries forward the full `ontology_suite` pipeline from the
sibling `consolidated_ontology_suite` checkout (OntoQA/OQuaRE metrics,
SHACL+SPARQL registry checks, OWL2 profile/reasoner-backed consistency,
docgen -- the same logic is also ported to TypeScript in
`consolidated_ontology_suite_webapp`, the VS Code extension) and adds three
things that didn't exist in Python before:

- **Ontology-version consistency + rename detection**
  (`ontology_suite.versioning.rename_detection`) -- pairs up a version
  diff's removed/added classes and properties into probable renames, using
  either an explicit `owl:equivalentClass`/`dcterms:isReplacedBy`
  migration annotation (high confidence) or local-name similarity
  (fallback).
- **Automated repair suggestions** (`ontology_suite.repair`,
  `ontology_suite.checks.repair`) -- turns a TARQL/ontology misalignment or
  a registry-check finding into a concrete unified diff: a `PREFIX` line
  fix, an IRI-rename substitution across a query file, an ontology
  declaration stub, or a real SPARQL 1.1 Update -- reviewable as a
  `.patch` file, or applied directly.
- **Live triplestore support** (`ontology_suite.remote`) -- runs the same
  checks against a Fuseki (or any SPARQL 1.1 Protocol) dataset, named-graph
  aware: diff two ontology *versions* held as separate named graphs, run
  the existing registry `.rq` checks scoped to exactly the graphs they
  should see, or three-way check a live triplified named graph against its
  ontology graph *and* its local TARQL source file.

Every `--ontology`/`--data`/query-source argument throughout accepts a
local file, an http(s) URL, or either gzip-compressed, transparently (see
`ontology_suite/io_utils.py` and `docs/ARCHITECTURE.md`'s "Loading files"
section).

**New here? Start with `docs/PRIMER.md`** -- a task-oriented guide to which
command answers which question, worked examples for every major use case
(auditing an ontology, validating a CSV-to-RDF pipeline, releasing a new
version, auto-repairing drift, taxonomy governance, live-triplestore
checks, CI wiring), and a suggested adoption path. New to RDF/OWL? It opens
with a short, plain-language glossary. Prefer running things over reading
them? `docs/primer.ipynb` is a Jupyter notebook covering most of the same
ground with live, executable cells against this repo's own `examples/`
fixtures (validated on every push by `.github/workflows/notebook.yml`).

See `docs/CONSISTENCY_AND_REPAIR.md` for the local-file workflow,
`docs/FUSEKI.md` for the live-triplestore one, `docs/ARCHITECTURE.md` for
the inherited pipeline this all sits on top of, and
`docs/UPSTREAM_README.md` for that pipeline's own original README.

## Quick start

```bash
uv sync
uv run ontology-quality-suite consistency --new domain-v2.ttl --old domain-v1.ttl --queries queries/
```

```python
from ontology_suite import consistency

report = consistency.check_consistency(
    "domain-v2.ttl", old_ontology="domain-v1.ttl", tarql_sources=["queries/"],
)
print(consistency.format_consistency_report(report))
consistency.apply_repairs(report.repairs, min_confidence=0.7)
```

## CLI

```
ontology-quality-suite ontology            --ontology domain.ttl
ontology-quality-suite checks              --ontology domain.ttl [--data data.ttl]
ontology-quality-suite sketch              --queries queries/ [--ontology domain.ttl]
ontology-quality-suite triplify            --csv-dir csv/ --queries queries/
ontology-quality-suite data                data.ttl [more.ttl ...] [--ontology domain.ttl]
ontology-quality-suite docgen              --ontology domain.ttl
ontology-quality-suite run                 whichever of --ontology/--queries/--csv-dir/--data apply
ontology-quality-suite version-diff        old.ttl new.ttl
ontology-quality-suite consistency         --new domain.ttl [--old domain-v1.ttl] [--queries queries/] [--apply-repairs]
ontology-quality-suite consistency-remote  --query-endpoint URL --manifest graphs.json
```

## Tests

```bash
uv run pytest
```
