Repository navigation
s2t: protect 是只有 / 是只能 from 是只 to 是隻 (#1304, #581) - #1433
Closed
stantheman0128 wants to merge 1 commit into
Closed
stantheman0128 wants to merge 1 commit into
stantheman0128 wants to merge 1 commit into
Conversation
…#1304) Keep the measure-word mapping 是只 -> 是隻, and add longer STPhrases entries so MaxMatch prefers 是只有 / 是只要 / 是只能 / 是只好 / 是只得 / 是只怕 over the two-character measure-word entry. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Jul 17, 2026
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 #1304.
Closes #581.
Problem
When 「只有」 is preceded by 「是」, default (non-jieba) conversion turns 「只」 into 「隻」:
Same MaxMatch path also breaks #581-style unquoted inputs such as 「则是只能」 and 「[全都不]是只能」 (both become 「…是隻能…」). The quoted report form 「则是「只」能」 already converts correctly on current master because the quotation marks break the 「是只」 phrase match.
Collaborator frankslin traced this to the STPhrases entry 「是只 -> 是隻」 (measure word). With jieba segmentation the same input converts correctly because 「只有」 is kept as one token; without jieba, MaxMatch takes the shorter 「是只」 first.
Change
Keep 「是只 -> 是隻」 for legitimate measure-word uses such as 「是只猫 -> 是隻貓」.
Add longer identity mappings in
STPhrases.txtso MaxMatch prefers the function-word reading:Tradeoff: this is the usual longer-phrase-wins pattern. It does not remove the measure-word entry. Other rare 「是只X」 collisions may still need similar protections later; the issue report and the common 「只*」 function words above are covered.
Dictionary sorted with
python data/scripts/sort.py data/dictionary/STPhrases.txt.Test plan
BYVoid_OpenCC_Issue_1304_*intest/testcases/testcases.jsonEvidence
Repro before (master STPhrases, text-dict s2t harness):
After this branch:
A/B of all existing
s2texpectations (master vs this STPhrases): only the new #1304 cases differ, as intended.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.