# sciknoworg/ontolearner architecture

> Architecture diagram of the GitHub repository sciknoworg/ontolearner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sciknoworg/ontolearner
- Repository: https://github.com/sciknoworg/ontolearner

## Overview

OntoLearner is a Python library for ontology learning with LLMs. Its principal workflow loads a built-in or custom ontology, extracts task data, optionally splits it for training and testing, runs a learner, and evaluates predictions. Distinct capabilities include ontology cataloguing and analysis, term typing, taxonomy discovery, non-taxonomic relation extraction, and Text2Onto generation. The graph includes the documented pipeline and major subsystems; unsampled implementation details are represented at their existing directory paths, and edges are limited to README-backed relationships or shown source references.

Main entry points: [`ontolearner/base/learner.py`](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/learner.py) (Learner API), [`ontolearner/processor.py`](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/processor.py) (Learner pipeline), [`ontolearner/base/ontology.py`](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/ontology.py) (Ontology loader), [`ontolearner/ontology`](https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/ontology) (Ontology catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ontology["Ontologies"]
  node_catalog["Ontology catalog"]
  node_ontology_base["Ontology loader<br/>[ontology.py]"]
  node_ontology_data["Extracted task data<br/>[data.py]"]
end

subgraph group_learning["Learning"]
  node_split["Train-test split"]
  node_learner_api["Learner API<br/>[learner.py]"]
  node_llm["LLM learners<br/>[llm.py]"]
  node_retriever["Retriever learners"]
  node_rag["RAG learner<br/>[rag.py]"]
  node_task_models["Task models"]
  node_pipeline["Learner pipeline<br/>[processor.py]"]
end

subgraph group_text["Text2Onto"]
  node_text_base["Text2Onto data<br/>[text2onto.py]"]
  node_text_generation["Text generation<br/>[synthesizer.py]"]
  node_text_split["Text splitting<br/>[splitter.py]"]
  node_text_batch["Text batching<br/>[batchifier.py]"]
end

subgraph group_analysis["Analysis"]
  node_evaluation["Evaluation metrics<br/>[metrics.py]"]
  node_metric_data["Metric structures<br/>[metric.py]"]
  node_analyzer["Ontology analyzer<br/>[analyzer.py]"]
  node_visualizer["Ontology visualizer<br/>[visualizer.py]"]
  node_io["Resource I/O<br/>[io.py]"]
end

node_user(("User"))

node_user -->|"selects ontology"| node_catalog
node_user -->|"loads and extracts"| node_ontology_base
node_catalog -->|"provides ontologizers"| node_ontology_base
node_ontology_base -->|"extracts task data"| node_ontology_data
node_user -->|"splits data"| node_split
node_user -->|"fits and predicts"| node_learner_api
node_learner_api -->|"supports LLM learners"| node_llm
node_learner_api -->|"supports retrievers"| node_retriever
node_learner_api -->|"supports RAG"| node_rag
node_learner_api -->|"supports learning tasks"| node_task_models
node_user -->|"evaluates predictions"| node_evaluation
node_evaluation -->|"returns metrics"| node_metric_data
node_user -->|"generates documents"| node_text_generation
node_text_generation -->|"uses batching"| node_text_batch
node_text_split -->|"builds text datasets"| node_text_base
node_user -->|"runs workflow"| node_pipeline
node_pipeline -->|"analyzes ontology"| node_analyzer
node_pipeline -->|"writes resources"| node_io
node_user -->|"visualizes ontology"| node_visualizer

click node_catalog "https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/ontology"
click node_ontology_base "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/ontology.py"
click node_ontology_data "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/data_structure/data.py"
click node_split "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/utils/train_test_split.py"
click node_learner_api "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/learner.py"
click node_llm "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/learner/llm.py"
click node_retriever "https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/learner/retriever"
click node_rag "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/learner/rag/rag.py"
click node_task_models "https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/learner"
click node_evaluation "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/evaluation/metrics.py"
click node_metric_data "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/data_structure/metric.py"
click node_text_base "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/text2onto.py"
click node_text_generation "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/synthesizer.py"
click node_text_split "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/splitter.py"
click node_text_batch "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/batchifier.py"
click node_pipeline "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/processor.py"
click node_analyzer "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/tools/analyzer.py"
click node_visualizer "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/tools/visualizer.py"
click node_io "https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/utils/io.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_catalog,node_ontology_base,node_ontology_data,node_user toneBlue
class node_split,node_learner_api,node_llm,node_retriever,node_rag,node_task_models,node_pipeline toneAmber
class node_text_base,node_text_generation,node_text_split,node_text_batch toneMint
class node_evaluation,node_metric_data,node_analyzer,node_visualizer,node_io toneRose
```

## Components

### Ontologies

- [Ontology catalog](https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/ontology): `ontolearner/ontology`
- [Ontology loader](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/ontology.py): `ontolearner/base/ontology.py`
- [Extracted task data](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/data_structure/data.py): `ontolearner/data_structure/data.py`

### Learning

- [Train-test split](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/utils/train_test_split.py): `ontolearner/utils/train_test_split.py`
- [Learner API](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/learner.py): `ontolearner/base/learner.py`
- [LLM learners](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/learner/llm.py): `ontolearner/learner/llm.py`
- [Retriever learners](https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/learner/retriever): `ontolearner/learner/retriever`
- [RAG learner](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/learner/rag/rag.py): `ontolearner/learner/rag/rag.py`
- [Task models](https://github.com/sciknoworg/ontolearner/tree/main/ontolearner/learner): `ontolearner/learner`
- [Learner pipeline](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/processor.py): `ontolearner/processor.py`

### Text2Onto

- [Text2Onto data](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/base/text2onto.py): `ontolearner/base/text2onto.py`
- [Text generation](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/synthesizer.py): `ontolearner/text2onto/synthesizer.py`
- [Text splitting](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/splitter.py): `ontolearner/text2onto/splitter.py`
- [Text batching](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/text2onto/batchifier.py): `ontolearner/text2onto/batchifier.py`

### Analysis

- [Evaluation metrics](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/evaluation/metrics.py): `ontolearner/evaluation/metrics.py`
- [Metric structures](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/data_structure/metric.py): `ontolearner/data_structure/metric.py`
- [Ontology analyzer](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/tools/analyzer.py): `ontolearner/tools/analyzer.py`
- [Ontology visualizer](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/tools/visualizer.py): `ontolearner/tools/visualizer.py`
- [Resource I/O](https://github.com/sciknoworg/ontolearner/blob/main/ontolearner/utils/io.py): `ontolearner/utils/io.py`

### Other components

- **User**

## Connections

- User → Ontology catalog: selects ontology (evidence: `README.md`)
- User → Ontology loader: loads and extracts (evidence: `README.md`)
- Ontology catalog → Ontology loader: provides ontologizers (evidence: `ontolearner/ontology/food_beverage.py`)
- Ontology loader → Extracted task data: extracts task data (evidence: `ontolearner/base/ontology.py`)
- User → Train-test split: splits data (evidence: `README.md`)
- User → Learner API: fits and predicts (evidence: `README.md`)
- Learner API → LLM learners: supports LLM learners (evidence: `ontolearner/learner/llm.py`)
- Learner API → Retriever learners: supports retrievers (evidence: `README.md`)
- Learner API → RAG learner: supports RAG (evidence: `README.md`)
- Learner API → Task models: supports learning tasks (evidence: `README.md`)
- User → Evaluation metrics: evaluates predictions (evidence: `README.md`)
- Evaluation metrics → Metric structures: returns metrics (evidence: `ontolearner/evaluation/metrics.py`)
- User → Text generation: generates documents (evidence: `README.md`)
- Text generation → Text batching: uses batching (evidence: `ontolearner/text2onto/synthesizer.py`)
- Text splitting → Text2Onto data: builds text datasets (evidence: `ontolearner/text2onto/splitter.py`)
- User → Learner pipeline: runs workflow (evidence: `README.md`)
- Learner pipeline → Ontology analyzer: analyzes ontology (evidence: `ontolearner/processor.py`)
- Learner pipeline → Resource I/O: writes resources (evidence: `ontolearner/processor.py`)
- User → Ontology visualizer: visualizes ontology
