This script generates text using an n-gram model built from a provided text file.
uv run main.py [file_path] [options]file_path: Path to the input text file. Required if not loading a model.
--n-gram-size: The size of the n-grams (default: 3).--num-words: The number of words to generate (default: 15).--seed: Random seed for reproducibility.--initial-words: A sequence of words to start the generation from. The number of words must ben-gram-size - 1.--load-model: Path to a saved model file to load.--save-model: Path to save the generated model.
Generate 20 words from data/jekyll.txt using a 3-gram model:
uv run main.py data/jekyll.txt --num-words 20Generate text with a 4-gram model and a specific starting sequence:
uv run main.py data/jekyll.txt --n-gram-size 4 --initial-words "he was not"Save a model:
uv run main.py data/jekyll.txt --save-model jekyll.modelLoad a model and generate text:
uv run main.py --load-model jekyll.model --num-words 50