Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A fast converter between Japanese hankaku and zenkaku characters

License

NotificationsYou must be signed in to change notification settings

studio-ousia/mojimoji

Repository files navigation

https://static.pepy.tech/personalized-badge/mojimoji?period=total&units=international_system&left_color=grey&right_color=orange&left_text=pip%20downloads

A Cython-based fast converter between Japanese hankaku and zenkaku characters.

Installation

$ pip install mojimoji

Examples

Zenkaku to Hankaku

>>>importmojimoji>>>print(mojimoji.zen_to_han('アイウabc012'))アイウabc012>>>print(mojimoji.zen_to_han('アイウabc012',kana=False))アイウabc012>>>print(mojimoji.zen_to_han('アイウabc012',digit=False))アイウabc012>>>print(mojimoji.zen_to_han('アイウabc012',ascii=False))アイウabc012

Hankaku to Zenkaku

>>>importmojimoji>>>print(mojimoji.han_to_zen('アイウabc012'))アイウabc012>>>print(mojimoji.han_to_zen('アイウabc012',kana=False))アイウabc012>>>print(mojimoji.han_to_zen('アイウabc012',digit=False))アイウabc012>>>print(mojimoji.han_to_zen('アイウabc012',ascii=False))アイウabc012

Benchmarks

Library versions

Results

In [19]:s='ABCDEFG012345'*10In [20]:%timeforninrange(1000000):mojimoji.zen_to_han(s)CPUtimes:user2.86s,sys:0.10s,total:2.97sWalltime:2.88sIn [21]:%timeforninrange(1000000):unicodedata.normalize('NFKC',s)CPUtimes:user5.43s,sys:0.12s,total:5.55sWalltime:5.44sIn [22]:%timeforninrange(1000000):zenhan.z2h(s)CPUtimes:user69.18s,sys:0.11s,total:69.29sWalltime:69.48s

Links

About

A fast converter between Japanese hankaku and zenkaku characters

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp