Skip to main content

A tool for generating ontological knowledge graphs with emotional embeddings from text.

Project description

Poetic Ontology Builder

Author: Willinton Triana Cardona
Version: 1.0.0

"Every text carries emotional weight. This tool extracts its meaning, weaves it into an ontology, and illuminates its emotional resonance"

Poetic Ontology Builder transforms any text into a living knowledge graph enriched with emotional embeddings.
It combines large language models for knowledge extraction (Gemini), Rosa (a fine‑tuned BERT model for GoEmotions), and ontology construction (OWL + RDF) into an interactive, beautiful visualization.


Features

  • Knowledge graph extraction:
    Extracts subject‑predicate‑object triplets with contextual qualifiers from any text.
  • Emotional embedding:
    Integrates ROSA — a fine‑tuned BERT model trained on the GoEmotions dataset — to detect and color‑map emotional tones.
  • Ontology export:
    Generates GraphDB‑ready OWL files for semantic storage and querying.
  • Interactive graph visualization:
    Force‑directed, emotion‑color‑coded graphs with poetic tooltips.
  • Emotional analytics:
    Exports emotion distribution JSON and a bar chart summarizing emotional fields.
  • Timestamped outputs:
    Each run produces a clean folder:
    outputs/YYYYMMDD_HHMMSS/
    ├── sublime_graph.owl
    ├── sublime_graph.html
    ├── emotion_stats.json
    ├── emotion_stats.png
    

Installation

Clone the repository and install in editable mode:

git clone https://github.com/yourusername/poetic_ontology_builder.git
cd poetic_ontology_builder
pip install -e .

Configuration

Create a .env file in the project root:

GEMINI_API_KEY=your_gemini_api_key
HF_TOKEN=your_huggingface_token

Usage

From a text file:

poetic-ontology path/to/textfile.txt

From an inline string:

poetic-ontology "And Socrates said: When the soul returns into itself..."

Open the interactive graph & emotion chart after generation:

poetic-ontology text.txt --open

Output

  1. Ontology:
    sublime_graph.owl — an RDF/OWL representation (GraphDB‑ready).
  2. Interactive Graph:
    sublime_graph.html — force‑directed graph with emotion‑colored nodes and tooltips.
  3. Emotion Analytics:
    • emotion_stats.json — raw emotional counts.
    • emotion_stats.png — a bar chart of the emotional field.

Emotional Palette

Each emotion is mapped to a distinct color based on its polarity and tone.
Example:

  • Joy / Love / Pride → Warm yellows & pinks
  • Grief / Fear / Anger → Deep blues & reds
  • Neutral → Gray

Roadmap

  • BFO/SUMO alignment for deeper ontological grounding
  • PyPI release for global access
  • Web interface for non‑technical users
  • Multi‑modal inputs (image + text)

Acknowledgements

  • ROSA: Emotional BERT model fine‑tuned on GoEmotions
  • Google Gemini: Triplet & knowledge extraction
  • OWLready2: Ontology management
  • PyVis: Interactive graph visualization

License

MIT License © 2025 Willinton Triana Cardona

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

poetic_ontology_builder-1.0.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

poetic_ontology_builder-1.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file poetic_ontology_builder-1.0.1.tar.gz.

File metadata

  • Download URL: poetic_ontology_builder-1.0.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for poetic_ontology_builder-1.0.1.tar.gz
Algorithm Hash digest
SHA256 aeb605c79a1645e0f8132f92595cf2b71c83a4685acbf7d682f4a143f97ca0bf
MD5 703831005490e01483ca28d304bd5679
BLAKE2b-256 9ab86d6af91e0e60b77ce820a2aca0fd266c4a0083a22e89ee3a7a06b7b70e59

See more details on using hashes here.

File details

Details for the file poetic_ontology_builder-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for poetic_ontology_builder-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b515e56d7396346ba83f8d3126a8b84b34d0483ecff6571c6d04824eb053cbe3
MD5 82af6fe73e40b05790843124db27af76
BLAKE2b-256 201b8be3850083112baf676385f949c6fe3a5d02a9d5fd7e88bc87a6ba50414a

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