Skip to content

fix: only use digit-by-digit reading for 4-digit years - #349

Merged
pengzhendong merged 2 commits into
masterfrom
fix/annual-four-digits
Jun 9, 2026
Merged

fix: only use digit-by-digit reading for 4-digit years#349
pengzhendong merged 2 commits into
masterfrom
fix/annual-four-digits

Conversation

@pengzhendong

@pengzhendong pengzhendong commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #302

Summary

Previously 2-digit numbers followed by 年/年度/赛季 were read digit-by-digit (e.g. 38年三八年). Now only 4-digit years use this pattern. Shorter numbers go through the normal number reading.

Examples

Input Before After
民国38年 民国三八年 民国三十八年
38年 三八年 三十八年
15年 一五年 十五年
2024年 二零二四年 二零二四年 (unchanged)
2024-2025赛季 二零二四到二零二五赛季 二零二四到二零二五赛季 (unchanged)

Test plan

  • All 1400 unit tests pass
  • CI passes

normalize(input, nbest=1) returns a single string (default, backward
compatible). normalize(input, nbest=N) returns a list of N-best results.

Example:
  n.normalize('海淀区108号', nbest=3)
  # ['海淀区一百零八号', '海淀区十八号', '海淀区幺零八号']
Previously 2-digit numbers followed by 年/年度/赛季 were read
digit-by-digit (38年 => 三八年). Now only 4-digit years use this
pattern, so 38年 => 三十八年 (via number) while 2024年 => 二零二四年.
@pengzhendong
pengzhendong merged commit aa078d0 into master Jun 9, 2026
1 check passed
@pengzhendong
pengzhendong deleted the fix/annual-four-digits branch June 9, 2026 11:55
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]民国38年会转换成民国三八年

1 participant