Model the context
The program uses an n-gram as its current context, allowing recent characters to influence the next generated character.
This project turned sample text into a probability model, then used that model to create output that balanced recognizable patterns with controlled randomness.
Project overview
I developed a C++ program that learns character patterns from training text using Markov chains and n-gram modeling. It calculates possible next-character probabilities and samples from those distributions to generate new text.
Engineering approach
The program uses an n-gram as its current context, allowing recent characters to influence the next generated character.
I calculated next-character probabilities from the training text so frequently observed transitions were more likely to be selected.
I tested different n-gram orders to compare coherence and randomness, using the results to understand the model's tradeoffs.
Technical highlights
Character-level probability modeling
N-gram context generation
Weighted probability sampling
Comparative testing across n-gram orders
What I learned
The project gave me practical experience translating a mathematical model into a working C++ system and evaluating behavior that is probabilistic rather than fixed.