Skip to content

fix: disambiguate X点零Y between time and decimal in Chinese ITN#343

Merged
pengzhendong merged 1 commit into
masterfrom
fix/time-decimal-ambiguity
Jun 9, 2026
Merged

fix: disambiguate X点零Y between time and decimal in Chinese ITN#343
pengzhendong merged 1 commit into
masterfrom
fix/time-decimal-ambiguity

Conversation

@pengzhendong

@pengzhendong pengzhendong commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #310

Summary

#310: Disambiguate "X点零Y" between time and decimal

"五点零三" was incorrectly parsed as time 5:03 instead of decimal 5.03. Fix: require suffix or noon prefix for zero-prefixed minutes (零一~零九). Non-zero minutes (半, 三十, etc.) are unaffected.

#309: Convert digit after 块 regardless of enable_0_to_9

十五块八 with enable_0_to_9=False now correctly outputs 15块8 instead of 15块八. The digit after is always converted as part of the monetary amount.

Examples

Input Before After
五点零三 5:03 5.03
下午五点零三 5:03p.m. 5:03p.m.
五点零三分 5:03 5:03
八点三十 8:30 8:30
十五块八 (enable_0_to_9=False) 15块八 15块8
十二块五毛 (enable_0_to_9=False) 12块五毛 12块5毛

Test plan

  • All 1400 unit tests pass
  • CI passes

"五点零三" was incorrectly parsed as time 5:03 instead of decimal 5.03.

Fix: require "分" suffix or noon prefix (上午/下午/etc.) for time patterns
with zero-prefixed minutes (零一~零九). Without either, these are now
treated as decimals.

- Split minute.tsv: move 零X entries to new minute_zero.tsv
- Time tagger: 零X minutes without "分" only match with noon prefix

Examples:
  五点零三 => 5.03 (decimal, no context)
  五点零三分 => 5:03 (time, has 分)
  下午五点零三 => 5:03p.m. (time, has noon)
  八点三十 => 8:30 (time, unambiguous)
@pengzhendong pengzhendong merged commit ae7f5c3 into master Jun 9, 2026
1 check passed
@pengzhendong pengzhendong deleted the fix/time-decimal-ambiguity branch June 9, 2026 09:21
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.

“x点零x”的小数数字ITN转换容易转换为时间。

1 participant