- Notifications
You must be signed in to change notification settings - Fork0
Yet Another Fast Japanese String Converter
License
NotificationsYou must be signed in to change notification settings
Hizuru3/python-habachen
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
日本語の全角/半角とひらがな/カタカナの相互変換をサポートする高速で省メモリな文字列変換モジュールです。
pip install habachen
# habachenモジュールをインポート>>>importhabachen# 半角から全角>>>habachen.han_to_zen('abc!?012ハンカクモジ')'abc!?012ハンカクモジ'# 半角カタカナのみを変換>>>text='abc!?012ハンカクモジ'>>>habachen.han_to_zen(text,ascii=False,digit=False,kana=True)'abc!?012ハンカクモジ'# 全角から半角>>>habachen.zen_to_han('abc!?012ゼンカクモジ')'abc!?012ゼンカクモジ'# 全角カタカナの変換を行わない>>>text='abc!?012ゼンカクモジ'>>>habachen.zen_to_han(text,kana=False)'abc!?012ゼンカクモジ'# ひらがなをカタカナに変換>>>habachen.to_katakana('もじれつの変換')'モジレツノ変換'# 指定したひらがなを無視>>>habachen.to_katakana('あいうえおかきくけこ',ignore='あか')'あイウエオかキクケコ'# ひらがなを半角カタカナに変換>>>habachen.to_katakana('もじれつの変換',hankaku=True)'モジレツノ変換'# 全角カタカナをひらがなに変換>>>habachen.to_hiragana('モジレツノ変換')'もじれつの変換'# 指定したカタカナを無視>>>habachen.to_hiragana('テストデス',ignore='ス')'てスとでス'
夢野久作『ドグラ・マグラ』
http://www.aozora.gr.jp/cards/000096/files/2093_ruby_28087.zip
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
habachen-0.3.0
mojimoji-0.0.12
jaconv-0.3.4
habachen | mojimoji | jaconv | |
---|---|---|---|
全角→半角 | 1.319 µs | 11.92 µs | 11.22 µs |
半角→全角 | 1.147 µs | 10.15 µs | 26.49 µs |
ひらがな→カタカナ | 0.3674 µs | 11.22 µs | |
カタカナ→ひらがな | 0.3542 µs | 10.97 µs |
habachen | mojimoji | jaconv | |
---|---|---|---|
全角→半角 | 2.607 ms | 55.07 ms | 40.36 ms |
半角→全角 | 1.832 ms | 33.89 ms | 57.16 ms |
ひらがな→カタカナ | 0.711 ms | 38.72 ms | |
カタカナ→ひらがな | 0.755 ms | 40.36 ms |
検証に用いたスクリプトはこちら
ドキュメント:https://hizuru3.github.io/python-habachen/
Qiita 記事:https://qiita.com/Hizuru/items/6b91d00fbe13ebb43867
About
Yet Another Fast Japanese String Converter
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.