Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example from readme fails to assert. #25

Closed
najamelan opened this issue Jan 24, 2020 · 1 comment
Closed

Example from readme fails to assert. #25

najamelan opened this issue Jan 24, 2020 · 1 comment

Comments

@najamelan
Copy link

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
use hyphenation::*;

fn main() -> Result<(), Box<dyn std::error::Error> >
{
	// 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<String> = 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
Copy link
Owner

Thanks for the exhaustive report.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants