Skip to main content

Kanji Converter to Hiragana, Katakana, Roman alphabet

Project description

kanjiconv

Japanese REAMED is here. (日本語のREADMEはこちらです。)
https://github.com/sea-turt1e/kanjiconv/blob/main/README_ja.md

kanjiconv

Kanji Converter to Hiragana, Katakana, Roman alphabet.
You can get the reading and pronunciation of Japanese sentences based on sudachidict.
Sudachidict is a regularly updated dictionary, so it can relatively handle new proper nouns and other terms.

Environments

macOS Sonoma 14.5
python==3.11.7

Install

Install kanjiconv

pip install kanjiconv

How to use

Import & Create Instance

from kanjiconv import KanjiConv
kanji_conv = KanjiConv(separator="/")

Get Reading

# convert to hiragana
text = "幽☆遊☆白書は、最高の漫画デス。"
print(kanji_conv.to_hiragana(text))
ゆうゆうはくしょ///さいこう//まんが/です/

# convert to katakana
text = "幽☆遊☆白書は、最高の漫画デス。"
print(kanji_conv.to_katakana(text))
ユウユウハクショ///サイコウ//マンガ/デス/

# convert to Roman alphabet
text = "幽☆遊☆白書は、最高の漫画デス。"
print(kanji_conv.to_roman(text))
yuuyuuhakusho/ha/, /saikou/no/manga/desu/. 

# You can change separator to another character or None
kanji_conv = KanjiConv(separator="_")
print(kanji_conv.to_hiragana(text))
ゆうゆうはくしょ_は__さいこう_の_まんが_です_

kanji_conv = KanjiConv(separator="")
print(kanji_conv.to_hiragana(text))
ゆうゆうはくしょはさいこうのまんがです

(Optional) Installing sudachidict other than the default

The default dictionary is sudachidict_full. If you want to use a lighter dictionary, you can install either sudachidict_small or sudachidict_core.

  • If you need detailed readings, we recommend using sudachidict_full. The default is set to sudachidict_full.
  • If you prefer lighter operation, sudachidict_small is recommended.
  • sudachidict_core offers a balanced option between speed and accuracy.
pip install sudachidict_small
pip install sudachidict_core
  • If using sudachidict_small or sudachidict_core, specify it like this:
kanji_conv = KanjiConv(sudachi_dict_type="small", separator="/")
kanji_conv = KanjiConv(sudachi_dict_type="core", separator="/")

Update Dict

kanjiconv reading function is based on SudachiDict, and you need to update SudachiDict regularly via pip.

pip install -U sudachidict_full
pip install -U sudachidict_small
pip install -U sudachidict_core

License

This project is licensed under the Apache License 2.0.

Open Source Software Used

This library uses SudachiPy and its dictionary SudachiDict for morphological analysis. These are also distributed under the Apache License 2.0.

For detailed license information, please refer to the LICENSE files of each project:

Project details


Download files

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

Source Distribution

kanjiconv-0.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

kanjiconv-0.1.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file kanjiconv-0.1.2.tar.gz.

File metadata

  • Download URL: kanjiconv-0.1.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

File hashes

Hashes for kanjiconv-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8611ac13c27693d0df6294fd01b0a10166d8ec41a7e2bcd1e2860b83c12dede1
MD5 9d40488407474e172408f99f500f2834
BLAKE2b-256 f77aed5c47481e48d35aace198106970814b86363973e3068d300d66d620e3c1

See more details on using hashes here.

File details

Details for the file kanjiconv-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: kanjiconv-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/6.5.0-1025-azure

File hashes

Hashes for kanjiconv-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 762a7ca8604a1c654d905238ea4b3e5e757cb88747db942b15fabd88e67720f7
MD5 6e86bd9121511d680bbc630da4793f2e
BLAKE2b-256 d5499acd0a006c50aefb3e87eec435af271155767866d9c627afbb9be057414d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page