You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
993 B
Markdown
12 lines
993 B
Markdown
---
|
|
# edu-6r70
|
|
title: 'Markov exercise: Bigram Text Generator (Rust)'
|
|
status: completed
|
|
type: task
|
|
priority: high
|
|
created_at: 2026-03-10T23:30:01Z
|
|
updated_at: 2026-03-10T23:30:01Z
|
|
---
|
|
|
|
Write Section 7 of edu/markov.md: Exercise 3 — Bigram Text Generator\n\nLearning objectives:\n- Build a HashMap-based transition table from a text corpus\n- Implement weighted random sampling over successor words\n- Generate and print novel word sequences from a seed\n\nContent to produce:\n- Setup instructions (new Cargo project or extend previous, add rand crate)\n- Step-by-step hints:\n 1. Tokenize corpus into words (split_whitespace)\n 2. Build BigramModel::train by iterating consecutive word pairs\n 3. Implement weighted sampling in generate (accumulate weights, compare to rng draw)\n 4. Handle end-of-chain gracefully (seed word not in model)\n 5. Try with a public-domain text (e.g., Project Gutenberg excerpt)\n- Full reference solution\n\nTarget: replace the stub in edu/markov.md §7
|