Repository navigation
s2t: protect 前头发生 from 头发 to 頭髮 MaxMatch (#586) - #1450
Closed
stantheman0128 wants to merge 1 commit into
Closed
stantheman0128 wants to merge 1 commit into
stantheman0128 wants to merge 1 commit into
Conversation
Add a longer STPhrases entry so 前头发生 becomes 前頭發生 instead of matching 头发 in the middle. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Closes #586.
Problem
Default (non-jieba) MaxMatch matches the shorter STPhrases entry
头发 -> 頭髮inside前头发生:Expected (issue body):
前頭發生.Same A(A/B)(B/C)C overlap pattern as #578 / #581 / #890 / #1304:
前+头发+生wins over前头+发生.Change
Keep
头发 -> 頭髮(and hair compounds such as剪头发).Add one longer STPhrases entry so MaxMatch prefers the reported phrase:
Same longer-phrase-wins pattern as #1433 (是只有 vs 是只) and #1440 (人参加 vs 人参). Dictionary sorted with
python data/scripts/sort.py data/dictionary/STPhrases.txt.Test plan
BYVoid_OpenCC_Issue_586_*intest/testcases/testcases.json前头发生under s2t / s2tw / s2twp / s2hk前头发/剪头发/头发still map to頭髮喉头发干/不断发生unchangedEvidence
Repro before (packaged wheel dictionaries = current published behavior):
After this branch (config JSONs with ocd2 refs switched to text, driving
data/dictionary/*.txton the branch):A/B of existing
s2texpectations intestcases.json(branch STPhrases vs expectations, excluding the new #586 cases): 92/92 same, 0 diffs.sort.pyidempotence onSTPhrases.txt: no diff.Please treat CI Bazel tests as authoritative; no local C++/Bazel toolchain was available here.
AI assistance
This fix was developed with AI assistance (Cursor / Grok) and verified locally as shown above.