Skip to content

s2t: protect 人参加 from 人参 to 人蔘 ginseng match (#890) - #1440

Closed
stantheman0128 wants to merge 1 commit into
BYVoid:masterfrom
stantheman0128:fix/890-canjia-renshen
Closed

stantheman0128 wants to merge 1 commit into
BYVoid:masterfrom
stantheman0128:fix/890-canjia-renshen

Conversation

@stantheman0128

Copy link
Copy Markdown
Contributor

Closes #890.

Problem

When a person-count 「人」 is immediately followed by verbs that start with 「参」 (参加 / 参与 / 参观 / ...), default (non-jieba) conversion matches the shorter STPhrases entry 「人参 -> 人蔘」 first:

s2t / s2hk: 100人参加了这次活动 -> 100人蔘加了這次活動
s2t / s2hk: 十二个人参与这个案件 -> 十二個人蔘與這個案件

s2tw / s2twp already look correct because TWVariants maps 「蔘 -> 參」 after the fact. Collaborator frankslin noted on the issue that s2hk is the regional mode that still shows the wrong form; HEAD also reproduces the same MaxMatch miss on plain s2t.

Related background: #258 (closed by adding TWVariants 「蔘->參」), which fixed Taiwan paths but not s2t / s2hk.

Change

Keep 「人参 -> 人蔘」 (and 人参果 / 人参精) for the plant reading.

Add longer STPhrases entries so MaxMatch prefers the verb reading:

人参与	人參與
人参会	人參會
人参军	人參軍
人参加	人參加
人参展	人參展
人参战	人參戰
人参政	人參政
人参考	人參考
人参谋	人參謀
人参见	人參見
人参观	人參觀
人参演	人參演
人参议	人參議
人参访	人參訪
人参赛	人參賽
人参选	人參選

Same longer-phrase-wins pattern as #1433 (是只有 vs 是只). Dictionary sorted with python data/scripts/sort.py data/dictionary/STPhrases.txt.

Test plan

  • New cases BYVoid_OpenCC_Issue_890_* in test/testcases/testcases.json
    • reported sentence under s2t / s2tw / s2twp / s2hk
    • 参、人参的繁简转换问题 #258-style 人参与 sentence
    • sibling verbs: 有人参加 / 派人参观 / 人人参考 / 三人参赛 / 五人参选
    • plant control: 人参 / 人参果 / 人参精 / 吃人参 still map to 人蔘 (s2t/s2hk) or 人參 (s2tw/s2twp)
  • Local verification with OpenCC 1.4.1 wheel + branch text dictionaries (see Evidence)
  • CI Bazel dictionary / command_line tests (authoritative)

Evidence

Repro before (packaged wheel dictionaries = current published behavior):

s2t / s2hk: 100人参加了这次活动 -> 100人蔘加了這次活動
s2t / s2hk: 十二个人参与这个案件 -> 十二個人蔘與這個案件
s2t / s2hk: 人参 -> 人蔘

After this branch (config JSONs with ocd2 refs switched to text, driving data/dictionary/*.txt on the branch):

s2t / s2hk: 100人参加了这次活动 -> 100人參加了這次活動
s2t / s2hk: 十二个人参与这个案件 -> 十二個人參與這個案件
s2t / s2hk: 人参 -> 人蔘
s2tw: 人参 -> 人參

A/B of existing s2t expectations in testcases.json (branch STPhrases vs expectations, excluding the new #890 cases): 92/92 same, 0 diffs.

sort.py idempotence on STPhrases.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.

Keep the plant mapping 人参 -> 人蔘, and add longer STPhrases entries so
MaxMatch prefers 人参加 / 人参与 / 人参观 and other common 人参* verbs over
the two-character ginseng entry (fixes s2t and s2hk; s2tw already recovered
via TWVariants 蔘->參).

Co-authored-by: Cursor <cursoragent@cursor.com>

@peterxy123 peterxy123 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

done

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

Successfully merging this pull request may close these issues.

「100人参加了这次活动」转化错误

3 participants