Skip to content

feat: add 亿级 support and strip commas for Chinese TN#337

Merged
pengzhendong merged 2 commits into
masterfrom
fix/comma-in-measure
Jun 9, 2026
Merged

feat: add 亿级 support and strip commas for Chinese TN#337
pengzhendong merged 2 commits into
masterfrom
fix/comma-in-measure

Conversation

@pengzhendong

@pengzhendong pengzhendong commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #223
Closes #284

Summary

  • 亿级支持 (tn 新增 億~千億 #223): Extend Cardinal number FST to handle 9-13 digit numbers using two 4-digit blocks (four_nonzero + + four_any) to prevent ambiguity with shorter numbers
  • 逗号处理 (tn 299,792,458米错误 #284): Strip western-style commas between digits in Measure rule via cdrewrite
  • 重构 Cardinal: Extract four_nonzero/four_any helpers, remove redundant add_weight and rmpunct from number patterns

Examples

Input Output
299,792,458米 两亿九千九百七十九万二千四百五十八米
100000001 一亿零一
1,000,000米 一百万米
999999999 九亿九千九百九十九万九千九百九十九
100000000 一亿
200000000 两亿

Test plan

  • All 1400 unit tests pass locally
  • No ambiguity in number paths for all tested cases
  • CI passes

Use cdrewrite to remove commas between digits before matching numbers
in the Measure rule, so western-formatted numbers like 1,000,000米
correctly normalize to 一百万米.

Note: numbers exceeding 万级 (>99,999,999) still need 亿级 support
in Cardinal (#223), which is tracked separately.
- Extend Cardinal number FST to support 亿级 (9-13 digit numbers)
  using two 4-digit blocks to prevent ambiguity with shorter numbers
- Strip commas between digits in Measure rule for western-formatted
  numbers like 299,792,458米
- Refactor Cardinal: extract four_nonzero/four_any helpers, remove
  redundant add_weight and rmpunct from number patterns

Examples:
  299,792,458米 => 两亿九千九百七十九万二千四百五十八米
  100000001 => 一亿零一
  1,000,000米 => 一百万米
@pengzhendong pengzhendong changed the title fix: strip commas in numbers for Chinese TN Measure feat: add 亿级 support and strip commas for Chinese TN Jun 9, 2026
@pengzhendong
pengzhendong merged commit 63d8edc into master Jun 9, 2026
1 check passed
@pengzhendong
pengzhendong deleted the fix/comma-in-measure branch June 9, 2026 08:28
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.

tn 299,792,458米错误 tn 新增 億~千億

1 participant