Ailln / cn2an

📦 快速转化「中文数字」和「阿拉伯数字」~ (最新特性:分数,日期、温度等转化)

Home Page:https://www.dovolopor.com/cn2an

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

目前版本仅支持转换中文数字,而不支持将中文句子中的数字转换成阿拉伯数字

bobkentt opened this issue · comments

commented

RT
比如
“用户增长最快的三个城市”
转换为
“用户增长最快的3个城市”

commented

你可以用「正则」把中文数字匹配出来,使用 cn2an 转化后再还原回去。

commented

方法参考这里

我打算近期在 v0.4 中加入这个功能。

commented

@bobkentt 请更新到最新的 0.4.0 版本,这个功能的基本版本已经上线。

import cn2an

output = cn2an.transform("我捡了一百块钱", "cn2an")
# or output = cn2an.transform("我捡了一百块钱")
print(output)
# 我捡了100块钱

output = cn2an.transform("我捡了100块钱", "an2cn")
print(output)
# 我捡了一百块钱