ontologist

ontologist

Release Build status License

A Python library for validating RDF data alignment with ontologies without requiring shape resources.

Why?

When working with Large Language Models (LLMs) to extract RDF data based on ontologies, it’s crucial to verify that the extracted data aligns correctly with the target ontology. While tools like pySHACL or PyShEx exist for RDF validation, they may require additional shape resources, or may fail on certain validation checks.

This library provides a programmatic approach to verify ontology alignment, making it particularly suitable for:

  • Validating LLM-extracted RDF data
  • Working with ontologies that lack shape definitions
  • Getting detailed violation reports for debugging and improvement

Installation

pip install ontologist

Quick Start

from rdflib import Graph
from ontologist import validate

# Load your ontology and data graphs
data = Graph().parse("your_data.ttl")
ontology = Graph().parse("your_ontology.ttl")

# Validate the data
is_valid, violations, report = validate(data, ontology)

print(report)
Validation Report
Conforms: False
Results (1):
PROPERTY type violation:
	Property 'ex:Prop1' of instance 'ex:Class1' can't have value of type 'http://www.w3.org/2001/XMLSchema#string' because it requires type 'http://www.w3.org/2001/XMLSchema#integer'.

Visit original content creator repository https://github.com/atomobianco/ontologist

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *