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

Set boundary_property with complex character and EOT #4903

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/segmenter/src/rule_segmenter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl<'l, 's, Y: RuleBreakType<'l, 's> + ?Sized> Iterator for RuleBreakIterator<'
self.advance_iter();
if self.is_eof() {
self.result_cache.clear();
self.boundary_property = self.data.complex_property;
return Some(self.len);
}
}
Expand Down
8 changes: 8 additions & 0 deletions components/segmenter/tests/word_rule_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ fn rule_status_th() {
assert_eq!(iter.next(), Some(21), "after 2nd word");
assert_eq!(iter.word_type(), WordType::Letter, "letter");
assert!(iter.is_word_like(), "Letter(Thai) is true");

assert_eq!(iter.next(), Some(33), "after 3rd word");
assert_eq!(iter.word_type(), WordType::Letter, "letter");
assert!(iter.is_word_like(), "Letter(Thai) is true");

assert_eq!(iter.next(), Some(42), "after 4th word and next is EOT");
assert_eq!(iter.word_type(), WordType::Letter, "letter");
assert!(iter.is_word_like(), "Letter(Thai) is true");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I think it's worth adding extra assertions at the end of the test


    assert_eq!(iter.next(), None, "EOT");
    assert_eq!(iter.word_type(), WordType::None, "none");
    assert!(!iter.is_word_like(), "None is false");

to make sure we fully test every word in the testcase. Same for other testcase in this file.

However, iter.word_type() returns WordType::Letter in rule_status_th(). I've tried added the same three assertions in rule_status_numeric_eof(), and it matches the expectations.

@makotokato Could you check if this is a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EOT seems to return previous word_type. I didn't define whether we should return any value...


/* The rule status functions are no longer public to non word break iterators.
Expand Down
Loading