{"id":3756,"library":"pykakasi","title":"pykakasi","description":"pykakasi is a Python Natural Language Processing (NLP) library that transliterates Japanese text (hiragana, katakana, and kanji) into rōmaji (Latin/Roman alphabet). It supports NFC-normalized characters and is based on the C-language kakasi library. The current version is 2.3.0, and while there isn't a strict release cadence, updates are made as needed.","status":"active","version":"2.3.0","language":"en","source_language":"en","source_url":"https://codeberg.org/miurahr/pykakasi","tags":["nlp","japanese","romanization","hiragana","katakana","kanji","transliteration"],"install":[{"cmd":"pip install pykakasi","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Provides a mapping database for the library's functionality.","package":"klepto","optional":false}],"imports":[{"note":"The `setMode()`, `getConverter()`, and `do()` methods (old API) are deprecated and will be removed in v3.0. Use the `kakasi().convert()` method for modern usage.","wrong":"from pykakasi import kakasi, wakati; k = kakasi(); k.setMode(...); conv = k.getConverter()","symbol":"kakasi","correct":"from pykakasi import kakasi"}],"quickstart":{"code":"import pykakasi\n\nkks = pykakasi.kakasi()\ntext = \"かな漢字交じり文\"\n\n# Configure conversion modes (optional, defaults to Hepburn romaji, no spaces)\nkks.setMode('H', 'a') # Hiragana to romaji\nkks.setMode('K', 'a') # Katakana to romaji\nkks.setMode('J', 'a') # Kanji to romaji\nkks.setMode('r', 'Hepburn') # Use Hepburn Romanization\nkks.setMode('s', True) # Add spaces\nkks.setMode('C', True) # Capitalize\n\nconverter = kks.getConverter()\nresult_old_api = converter.do(text)\nprint(f\"Old API result: {result_old_api}\")\n\n# Recommended new API (v2.0.0+)\nresult_new_api = pykakasi.kakasi().convert(text)\nprint(\"\\nNew API result (default modes):\")\nfor item in result_new_api:\n    print(f\"Original: {item['orig']}, Kana: {item['kana']}, Hiragana: {item['hira']}, Romaji: {item['hepburn']}\")","lang":"python","description":"Initializes the kakasi converter and demonstrates both the deprecated (v1.x) and the recommended (v2.x) API for converting Japanese text into romaji, hiragana, and katakana. The new API offers a more streamlined `convert()` method."},"warnings":[{"fix":"Rewrite code using `kakasi().convert(text)` for conversion. For custom options, `kakasi` can be configured before calling `convert` or by passing a dictionary of options to its constructor (refer to official docs for full options).","message":"The old API methods (`setMode()`, `getConverter()`, `do()`, and the `wakati` class) are deprecated in pykakasi v2.1.0 and will be removed entirely in v3.0. Migrate to the `kakasi().convert()` method for future compatibility.","severity":"deprecated","affected_versions":">=2.1.0"},{"fix":"Review your project's licensing requirements. If GPLv3+ is incompatible, consider alternative Japanese romanization libraries with more permissive licenses (e.g., MIT or BSD).","message":"pykakasi is distributed under the GNU General Public License v3.0 or later (GPLv3+). This license has implications for commercial use, potentially requiring source code disclosure if the library is incorporated into proprietary software.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure input text is normalized to NFC before processing with pykakasi, e.g., using `unicodedata.normalize('NFC', text)`.","message":"The library primarily expects Unicode characters in Normalization Form C (NFC). Using text in Normalization Form D (NFD) might lead to incorrect or unexpected conversion results due to separated diacritics.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `https://codeberg.org/miurahr/pykakasi` as the primary source for the project, documentation, and issue tracking.","message":"The original GitHub repository (miurahr/pykakasi) was archived in July 2022 and now points to Codeberg. Users looking for the official source or contributing should refer to the Codeberg repository.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware of the potential for slower maintenance. For mission-critical applications requiring active development or immediate support, evaluate the project's current activity or consider alternatives.","message":"According to some analyses (e.g., Snyk report mentioned in a blog post), the project's maintenance status has been rated as 'Inactive,' despite its continued widespread usage. This might indicate slower response times for issues or new feature development.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}