test: assert 々 iteration mark does not corrupt name readings#16
Merged
test: assert 々 iteration mark does not corrupt name readings#16
Conversation
Add four tests guarding against the regression where the IDEOGRAPHIC
ITERATION MARK (々, U+3005) leaks into hiragana readings:
- test_nene_iteration_mark_given_name_only: 寧々 → ねね (single name)
- test_nene_iteration_mark_with_family_name: 田中寧々 reading has no 々
- test_ririko_iteration_mark_in_name: 莉々子 reading is non-empty and
has no 々
- test_iteration_mark_in_family_name_with_space: 須々木 心一 with hints
々 is outside the CJK Unified Ideographs range (0x4E00–0x9FFF) so
is_kanji() returns false for it. The kanji→kana boundary heuristic can
therefore treat it as a kana character, producing a split where 々 is
the entire given-name part. kata_to_hira("々") passes it through
unchanged, resulting in 々 appearing as the reading.
https://claude.ai/code/session_01BLRvapZFYvE1LpBxaHshsF
Root cause: is_kanji() did not include the IDEOGRAPHIC ITERATION MARK
(々, U+3005) because it sits outside all CJK Unified Ideographs blocks.
This caused two linked failures in the name-parsing pipeline:
1. find_split_point Strategy 1 detected a kanji→non-kanji boundary at
the 々 character, potentially isolating 々 as the entire given-name
part (e.g. 寧々 → family="寧", given="々").
2. With given_jp = "々", contains_kanji("々") returned false, so
kata_to_hira("々") was used instead of the hint reading.
kata_to_hira passes 々 through unchanged, producing a literal 々 in
the output (e.g. "ねね々" instead of "ねね").
Fix: add `|| code == 0x3005` to is_kanji(). 々 repeats the preceding
kanji (寧々 = 寧寧 = "nene"), so classifying it as kanji is semantically
correct and fixes both the boundary detection and the reading fallback.
A regression test (test_nene_iteration_mark_both_hints_triggers_split)
was added that failed before this fix and now passes.
https://claude.ai/code/session_01BLRvapZFYvE1LpBxaHshsF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add four tests guarding against the regression where the IDEOGRAPHIC
ITERATION MARK (々, U+3005) leaks into hiragana readings:
has no 々
々 is outside the CJK Unified Ideographs range (0x4E00–0x9FFF) so
is_kanji() returns false for it. The kanji→kana boundary heuristic can
therefore treat it as a kana character, producing a split where 々 is
the entire given-name part. kata_to_hira("々") passes it through
unchanged, resulting in 々 appearing as the reading.
https://claude.ai/code/session_01BLRvapZFYvE1LpBxaHshsF