Skip to main content

Dream journal analyzer with symbolic reasoning - hybrid Prolog rules + embeddings

Project description

Dream Decoder

Ko-fi

Buy Me A Coffee

A dream journal analyzer that combines Prolog-based symbolic reasoning with neural embeddings for dream interpretation and pattern analysis.

Features

  • Symbol Extraction: Automatically detects dream symbols using both keyword matching and semantic embeddings (sentence-transformers)
  • Symbolic Reasoning: Prolog rules for psychological interpretation of dream symbols, with Python fallback
  • Pattern Analysis: Tracks recurring themes, symbol associations, and temporal patterns
  • Visualization: Generate charts for symbol frequencies, theme timelines, and association networks
  • CLI Interface: Full command-line interface for managing your dream journal

Installation

# Clone the repository
git clone https://github.com/yourusername/dream-decoder.git
cd dream-decoder

# Install with pip
pip install -e .

Optional: SWI-Prolog

For full symbolic reasoning capabilities, install SWI-Prolog:

# Ubuntu/Debian
sudo apt-get install swi-prolog

# macOS
brew install swi-prolog

# Windows
# Download from https://www.swi-prolog.org/download/stable

If SWI-Prolog is not available, the system automatically falls back to Python-based reasoning.

Quick Start

CLI Usage

# Add a new dream
dream-decoder add --title "Flying Dream" --mood peaceful --lucidity 7

# View recent dreams
dream-decoder list

# View a specific dream
dream-decoder view 1

# Search dreams
dream-decoder search "ocean"

# Find dreams with a symbol
dream-decoder symbol water

# Get journal statistics
dream-decoder stats

# Analyze patterns
dream-decoder patterns

# Generate visualizations
dream-decoder visualize --output ./charts

# Export journal
dream-decoder export --format markdown --output dreams.md

Library Usage

from dream_decoder import DreamJournal

# Create a journal
journal = DreamJournal(db_path="my_dreams.db")

# Add a dream
entry = journal.add_dream(
    content="I was flying over a vast ocean when suddenly I started falling...",
    title="Flying and Falling",
    mood="anxious",
    lucidity=5,
)

# View analysis results
print(f"Symbols: {entry.symbols}")
print(f"Themes: {entry.themes}")
print(f"Interpretations: {entry.interpretations}")

# Find similar dreams
similar = journal.find_similar_dreams(entry, limit=5)

# Get recurring patterns
patterns = journal.pattern_analyzer.detect_recurring_patterns()

# Predict likely themes for future dreams
predictions = journal.predict_themes()

Architecture

dream_decoder/
├── storage.py      # SQLite database layer with DreamEntry model
├── journal.py      # Main interface coordinating all components
├── symbols.py      # Embedding-based symbol extraction
├── reasoning.py    # Prolog interface with Python fallback
├── patterns.py     # Pattern detection and statistical analysis
├── visualization.py # Matplotlib/NetworkX visualizations
├── cli.py          # Click-based CLI
└── rules/
    └── symbols.pl  # Prolog knowledge base

Hybrid AI Approach

  1. Symbol Extraction: Uses sentence-transformers (all-MiniLM-L6-v2) to compute embeddings and find semantically similar symbols
  2. Symbolic Reasoning: Prolog rules define relationships between symbols, emotions, and themes
  3. Pattern Analysis: Statistical analysis of symbol co-occurrences and temporal patterns
  4. Clustering: K-means clustering on dream embeddings to find related dreams

Dream Symbols

The system recognizes 60+ common dream symbols across categories:

Category Examples
Nature water, ocean, forest, mountain, fire, storm
Places house, school, bridge, door, stairs, basement
People mother, father, stranger, shadow_figure
Animals snake, spider, bird, wolf, butterfly
Actions flying, falling, running, being_chased, drowning
Objects key, mirror, clock, money, car

Detected Themes

  • Transformation: snake, butterfly, death, fire
  • Anxiety: falling, being_chased, teeth_falling, naked
  • Spiritual Journey: stairs, mountain, flying, bird
  • Relationships: mother, father, friend, stranger
  • Shadow Work: shadow_figure, monster, basement
  • Freedom Seeking: flying, bird, ocean, running
  • Emotional Processing: water, ocean, rain, drowning

CLI Commands

Command Description
add Add a new dream entry
view <id> View a specific dream
list List recent dreams
search <query> Search dream content
symbol <name> Find dreams with a symbol
similar <id> Find similar dreams
analyze <id> Re-analyze a dream
delete <id> Delete a dream
stats Show journal statistics
patterns Analyze recurring patterns
interpret <symbol> Get symbol interpretations
visualize Generate visualization charts
export Export journal to JSON/Markdown

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=dream_decoder

License

MIT License

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

dream_decoder-0.1.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

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

dream_decoder-0.1.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file dream_decoder-0.1.0.tar.gz.

File metadata

  • Download URL: dream_decoder-0.1.0.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dream_decoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 75a0298d6e8c1484b5f99a01cb33852dcfb2d8f4fcb8b2e88f06c9a2138d145e
MD5 039528a73e72fe4b051f1a3e8b05c48e
BLAKE2b-256 4663351ac06055c8c12c88cf80bd0fe0738b6342ce20d5426746a415ffd9e497

See more details on using hashes here.

File details

Details for the file dream_decoder-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dream_decoder-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dream_decoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 742eef7506cf9f98794e12df9b53b84f5d04fa2d43a163a10b619b12f4950e56
MD5 ebaf7c281304c0e0965eeb2fc98b48e2
BLAKE2b-256 90e75dfb5b3cadb2d38a020a0c2b474119e39dfd7e085fe13e970e0f6221c6e2

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