nagataaaas / kanjize Goto Github PK
View Code? Open in Web Editor NEWKanjize(カンジャイズ): Easy converter between Kanji-Number and Integer
License: MIT License
Kanjize(カンジャイズ): Easy converter between Kanji-Number and Integer
License: MIT License
Hi, mixed ascii number with kanji are not working for some case. I think previously it was working (on 0.1.0?). I would appreciate if you library support it.
> import kanjize
> kanjize.__version__
'0.2.0'
> from kanjize import kanji2int
> kanji2int('4百万')
4
Amazing library. Surprised to find a bug:
Current:
>>> number2kanji(01, config=KanjizeConfiguration(style=KanjizeStyle.FLAT)))
File "<stdin>", line 1
number2kanji(01, config=KanjizeConfiguration(style=KanjizeStyle.FLAT)))
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Expected:
print(number2kanji(01, config=KanjizeConfiguration(style=KanjizeStyle.FLAT)))
# 〇一
Hello,
This library helps me a lot. Thank you.
But it seems tricky when trying to convert serial number like 012-345-6789, because there is no kanji representing 0 in the dictionary.
Is there any reason for not including 0 in the dictionary?
Thank you very much for your reply for advance.
"5000兆円欲しい!" のようにアラビア数字・漢数字混じりの表記が見られます。オプションを渡すことで表記法を切り替える機能を希望します。
from kanjize import int2kanji
int2kanji(5000000000000000, format='mixed') # 5000兆
便利なライブラリを開発していただきありがとうございます。
使用している際に小数点を含む漢字表記に対して思うような結果がでなかったので報告させていただきます。
from kanjie import knji2int
print(kanji2int('1.5億'))
# 500000001
「int」と漢数字の変換の趣旨にずれるのかもしれませんが、このような場合はエラーを出す等だけでも良いと思いますのでお手隙の際に対処していただければ幸いです。
漢数字と算用数字の変換を探していたら、delta114514さんのKanjizeを発見しました。
早速、組み込ませて頂いたのですが、テストの段階で、漢数字→算用数字の変換のバグを発見しました。
import kanjize
print(kanjize.kanji2int("一億二千三百四十五万六千七百八十九"))
print(kanjize.kanji2int("一兆二千三百四十五万六千七百八十九"))
print(kanjize.kanji2int("十五億二千三百四十五万六千七百八十九"))
実行結果は
1000023456789(期待結果は、123456789)
10000000023456789(期待結果は、1000023456789)
1523456789(期待結果通り)
となりました。
お手すきの際にでも修正があると嬉しいです
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.