Skip to main content

A port of WanaKana, a JS library by Tofugu

Project description

ワナカナ <--> WanaKana <--> わなかな
Python utility library for detecting and transliterating Hiragana, Katakana, and Romaji

This library uses Semantic Versioning

See what this means here

Demo

Visit the website to see WanaKana in action.

Usage

Install

pip install wanakana-python
import wanakana
# or
from wanakana import to_kana, is_romaji

Documentation

Extended API reference (Note that function names are converted to snake_case)

Quick Reference

### TEXT CHECKING UTILITIES ###
wanakana.is_japanese('泣き虫。!〜2¥zenkaku')
# => True

wanakana.is_kana('あーア')
# => True

wanakana.is_hiragana('すげー')
# => True

wanakana.is_katakana('ゲーム')
# => True

wanakana.is_kanji('切腹')
# => True
wanakana.is_kanji('勢い')
# => False

wanakana.is_romaji('Tōkyō and Ōsaka')
# => True

wanakana.to_kana('ONAJI buttsuuji')
# => 'オナジ ぶっつうじ'
wanakana.to_kana('座禅‘zazen’スタイル')
# => '座禅「ざぜん」スタイル'
wanakana.to_kana('batsuge-mu')
# => 'ばつげーむ'
wanakana.to_kana('wanakana', custom_kana_mapping={'na': 'に', 'ka': 'bana'})
# => 'わにbanaに'

wanakana.to_hiragana('toukyou, オオサカ')
# => 'とうきょう、 おおさか'
wanakana.to_hiragana('only カナ', ignore_romaji=True)
# => 'only かな'
wanakana.to_hiragana('wi', use_obsolete_kana=True)
# => 'ゐ'

wanakana.to_katakana('toukyou, おおさか')
# => 'トウキョウ、 オオサカ'
wanakana.to_katakana('only かな', ignore_romaji=True)
# => 'only カナ'
wanakana.to_katakana('wi', use_obsolete_kana=True)
# => 'ヰ'

wanakana.to_romaji('ひらがな カタカナ')
# => 'hiragana katakana'
wanakana.to_romaji('ひらがな カタカナ', uppercase_katakana=True)
# => 'hiragana KATAKANA'
wanakana.to_romaji('つじぎり', custom_romaji_mapping={'じ': 'zi', 'つ': 'tu', 'り': 'li' })
# => 'tuzigili'

### EXTRA UTILITIES ###
wanakana.strip_okurigana('お祝い')
# => 'お祝'
wanakana.strip_okurigana('踏み込む')
# => '踏み込'
wanakana.strip_okurigana('お腹', leading=True)
# => '腹'
wanakana.strip_okurigana('ふみこむ', match_kanji='踏み込む')
# => 'ふみこ'
wanakana.strip_okurigana('おみまい', match_kanji='お祝い', leading=True)
# => 'みまい'

wanakana.tokenise('ふふフフ')
# => ['ふふ', 'フフ']
wanakana.tokenise('hello 田中さん')
# => ['hello', ' ', '田中', 'さん']
wanakana.tokenise('I said 私はすごく悲しい', compact=True)
# => [ 'I said ', '私はすごく悲しい']

Contributors

Credits

Port of WanaKana

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wanakana-python, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size wanakana-python-1.1.0.tar.gz (14.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page