Skip to content

Commit

Permalink
try to fix issue: netease-youdao#164 , support version number (like 5…
Browse files Browse the repository at this point in the history
….4.0) to chinese
  • Loading branch information
lvscar committed Oct 21, 2024
1 parent bc2de8c commit dd095fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend_cn.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ def has_english_punctuation(text):
re_digits = re.compile('(\d[\d\.]*)')
def number_to_chinese(number):
an2cn = An2Cn()
result = an2cn.an2cn(number)

n_parts = number.split(".")
if len(n_parts) > 2:
result = an2cn.an2cn('.'.join(n_parts[:2]))
for n in n_parts[2:]:
result += an2cn.an2cn(f"0.{n}")[1:]
else:
result = an2cn.an2cn(number)
return result

def tn_chinese(text):
Expand Down

0 comments on commit dd095fe

Please sign in to comment.