tapeinosyne / hyphenation

Text hyphenation for Rust
Apache License 2.0
53 stars 12 forks source link

Example from readme fails to assert. #25

Closed najamelan closed 4 years ago

najamelan commented 4 years ago

Apparently the word "hyphenation" gives opportunities as 2, 6 and 7...

Dunno which ones are correct, but it doesn't correspond to what's in the readme. Myriam Webster dictionary shows: hy·​phen·​ate.

Affected version 0.7.1. No other versions where tested.

Full code to reproduce ```rust use hyphenation::*; fn main() -> Result<(), Box > { // Retrieve the embedded American English dictionary for `Standard` hyphenation. let en_us = Standard::from_embedded(Language::EnglishUS) ?; // Identify valid breaks in the given word. let hyphenated = en_us.hyphenate("hyphenation"); // Word breaks are represented as byte indices into the string. let break_indices = &hyphenated.breaks; assert_eq!(break_indices, &[2, 6]); // The segments of a hyphenated word can be iterated over. let segments = hyphenated.into_iter(); let collected : Vec = segments.collect(); assert_eq!(collected, vec!["hy", "phen", "ation"]); // `hyphenate()` is case-insensitive. let uppercase : Vec<_> = en_us.hyphenate("CAPITAL").into_iter().collect(); assert_eq!(uppercase, vec!["CAP", "I", "TAL"]); Ok(()) } ```
tapeinosyne commented 4 years ago

Thanks for the exhaustive report.

The mismatch has been fixed in commit 0a0861c99f, and a test added to cover it.