How tharana-dev/markov-chain-generator works
This is a dependency-free Markov text generator and word-transition graph toolkit. The demo workflow samples a local corpus, tokenizes it into sentences, builds transition and starter-frequency data, then produces text and graph-search results for terminal and append-only log output. The tokenizer, model, generation, and search stages are distinct; logging is documented and visible in the demo. Edges reflect calls shown in the excerpts or README; no separate external service is involved.
Main entry points: main.py Demo Orchestrator · chain.py Transition Counts · tokenizer.py Sentence Tokenizer
Components 17
Text Processing
- Sentence Tokenizer
tokenizer.py - Capitalization Look-ahead
tokenizer.py
Markov Engine
- Chain Data Builder
chain.py - Starter Frequencies
chain.py - Transition Counts
chain.py - Weighted Selection
chain.py - Text Generation
chain.py - Lazy Generation
chain.py
Graph Search
- Reachability DFS
chain.py - Backtracking DFS
chain.py - Shortest-Path BFS
chain.py - Path Reconstruction
chain.py
Demo and Output
- Demo Orchestrator
main.py
Other components
- User
- Sample Corpus
- Terminal
- Historical Log
Connections 22
- User → Demo Orchestrator: runs
readme.md - Demo Orchestrator → Sample Corpus: samples
main.py - Demo Orchestrator → Sentence Tokenizer: tokenizes
main.py - Sentence Tokenizer → Capitalization Look-ahead: checks casing
tokenizer.py - Demo Orchestrator → Chain Data Builder: builds data
main.py - Chain Data Builder → Starter Frequencies: counts starts
chain.py - Chain Data Builder → Transition Counts: counts transitions
chain.py - Demo Orchestrator → Text Generation: generates text
main.py - Text Generation → Weighted Selection: selects tokens
chain.py - Weighted Selection → Starter Frequencies: weights start
chain.py - Weighted Selection → Transition Counts: weights follower
chain.py - Demo Orchestrator → Lazy Generation: requests stream
main.py - Lazy Generation → Weighted Selection: selects tokens
chain.py - Demo Orchestrator → Reachability DFS: finds reachable words
main.py - Reachability DFS → Transition Counts: traverses edges
chain.py - Demo Orchestrator → Backtracking DFS: finds route
main.py - Backtracking DFS → Transition Counts: traverses edges
chain.py - Demo Orchestrator → Shortest-Path BFS: finds shortest route
main.py - Shortest-Path BFS → Transition Counts: traverses edges
chain.py - Shortest-Path BFS → Path Reconstruction: reconstructs route
chain.py - Demo Orchestrator → Terminal: prints results
main.py - Demo Orchestrator → Historical Log: appends run
main.py