Repository navigation
s2t: 新增「这周/那周/若干周/周线 → 週」及 周围/周边/周遭 分詞保護詞條 - #1428
Merged
Merged
Conversation
Convert demonstrative/quantified week expressions and the financial term
周线 (weekly candlestick chart) to 週, while adding longer phrase entries
for 周围/周边/周遭 so segmentation keeps them as 周-based words.
Detailed Changes:
- **STPhrases.txt**:
- Add 这周/那周/若干周 -> 這週/那週/若干週 and 周线 -> 週線.
- Add 这/那/若干 + 周围/周边/周遭 identity-style entries to prevent
the new time-word keys from stranding 圍/邊/遭 after a wrong 週.
- **testcases.json**:
- Add case_065_s2x and case_066_t2x covering s2t/s2tw and t2s round-trip.
Collaborator
|
How about |
Cover 几周/多少周 and every existing X几 key (十几, 几十, 好几, 这几, 那几, 哪几, 过几, 第几) that would otherwise strand a following 周 in segmentation, plus 周围/周边/周遭 protection entries for the new short keys.
Owner
Author
|
已在 Generated by Claude Code |
BYVoid
marked this pull request as ready for review
July 15, 2026 00:39
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.
背景
STPhrases.txt已收錄上周 → 上週、下周 → 下週、本周 → 本週、每周 → 每週等時間詞,但「这周」「那周」「若干周」「几周」「多少周」以及金融術語「周线」(按週聚合的 K 線圖)一直缺失,s2t目前輸出這周/那周/幾周/週線等,「週」字丟失。修改內容
data/dictionary/STPhrases.txt(29 條,已用data/scripts/sort.py排序):这周 → 這週、那周 → 那週、若干周 → 若干週、周线 → 週線。几周 → 幾週、多少周 → 多少週,並逐一排查所有以几結尾、會在分詞時把後面周孤立的既有 key,一併收錄:十几周/几十周/好几周/这几周/那几周/哪几周/过几周/第几周 → …幾週。这/那/若干/几/多少 + 周围/周边/周遭。這些是必需的:mmseg 最長匹配會優先吃掉新增的这周/几周等 key,導致「这周围」被切成这周|围而誤轉為「這週圍」。加上更長的詞條後,分詞恢復正確邊界。茶几周围等由既有茶几詞條天然保護。test/testcases/testcases.json:新增case_065_s2x/case_066_t2x(这/那/若干/周线 組)與case_067_s2x/case_068_t2x(几/多少 組),覆蓋 s2t、s2tw 與 t2s 往返及「若干周边设备」「多少周边产品」「茶几周围」回歸場景。邊界情況驗證
这周先匹配,後接末/日/期仍為「週」,結果正確刹那先於那周被最長匹配消耗,不受影響茶几詞條天然保護反向(
t2s)由TSCharacters的週 → 周字符級處理,這週 → 这周、幾週 → 几周、週線 → 周线往返一致,無需新增 TSPhrases 詞條。已知取捨:與既有
上周/本周詞條相同,「这周密」「这周折」這類「这 + 周密/周折」的切分歧義會偏向時間詞解讀,屬字典式分詞的固有限制,本 PR 未擴大該影響面。驗證
.ocd2後實測:上表所有輸入及 29 條新詞條輸出均符合預期。testcases.json共 217 例:新增 4 例通過,其餘與 master 完全一致(master 上既有的 3 例本地 runner 差異與本修改無關)。🤖 Generated with Claude Code
https://claude.ai/code/session_016gfvxMkb2y5mdasr7GzF1y