Skip to content

Commit

Permalink
fix(itn): 多个数字之间加空格 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingchensong authored Oct 30, 2023
1 parent 0f2c8a2 commit 94c3eb2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions itn/chinese/rules/cardinal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def build_tagger(self):
digits = zero | digit # 0 ~ 9

# 十一 => 11, 十二 => 12
teen = cross('十', '1') + (digit | addzero)
teen = cross('十', '1') + (digit | add_weight(addzero, 0.1))
# 一十一 => 11, 二十一 => 21, 三十 => 30
tens = digit + delete('十') + (digit | addzero)
tens = digit + delete('十') + (digit | add_weight(addzero, 0.1))
# 一百一十 => 110, 一百零一 => 101, 一百一 => 110, 一百 => 100
hundred = (digit + delete('百') + (tens
| teen
Expand Down Expand Up @@ -123,5 +123,6 @@ def build_tagger(self):
cardinal |= number
else:
cardinal |= number_exclude_0_to_9
tagger = insert('value: "') + cardinal + insert('"')
tagger = insert('value: "') + cardinal + (insert(" ") + cardinal).star \
+ insert('"')
self.tagger = self.add_tokens(tagger)

0 comments on commit 94c3eb2

Please sign in to comment.