Skip to main content

日本語→自然なローマ字・英語変換ライブラリ(kakasi/SudachiPyベース+外来語辞書対応)

Project description

romann

日本語テキストを自然なローマ字や英語表記に変換するPythonライブラリです。 曲名・人名・外来語などを、視認性の高いローマ字や本来のスペルで出力します。 液晶ディスプレイや海外向け表示などにご活用いただけます。

主な特徴

  • SudachiPyによる高精度な形態素解析
  • 外来語は辞書に基づき英語表記に自動変換(カスタマイズ可)
  • 4x8ドット液晶でも読みやすいローマ字表記
  • Python 3.12対応・TDDによる品質管理

変換例

日本語 ローマ字 英語表記
アース・ウィンド&ファイアー Aasu Wind & Faiaa Earth Wind And Fire
いけないボーダーライン Ikenai Boodaa Rain Ikenai Border Line
さよならCOLOR Sayonara Color Sayonara Color
釈迦・イン・ザ・ハウス Shaka In Za Hausu Shaka In The House

動作環境

  • Python 3.12
  • 主要依存: SudachiPy, pykakasi, jaconv

インストール

pip install romann

使い方

from romann import RomanConverter
converter = RomanConverter()
print(converter.to_roman("薔薇の花"))  # Bara No Hana
print(converter.to_roman("アース・ウィンド&ファイアー"))  # Earth Wind & Fire

変換ルール

  • 単語の先頭は大文字、スペース区切り
  • 外来語は辞書にあれば英語表記、なければローマ字
  • 記号類はそのまま(「、」「。」は「,」「.」に変換)
  • 前後・連続する空白は整理

外来語辞書のカスタマイズ

外来語の変換は hiragana_english.json および katakana_english.json に基づきます。 これらを編集することで、特定単語の変換方法を調整できます。

例(hiragana_english.json):

{
  "あーす": "earth",
  "どあ": "door"
}
  • hiragana_english.json: ひらがな→英語表記
  • katakana_english.json: カタカナ→英語表記

関連


ご利用・フィードバック・Issue歓迎します。

  • 連続する空白は1つの空白に変換

インストール

pip install romann

依存ライブラリ

  • pykakasi: 日本語のローマ字変換
  • SudachiPy: 形態素解析
  • jaconv: 文字コード変換

使用方法

from romann import RomanConverter

converter = RomanConverter()

# 日本語テキストをローマ字に変換
text = "薔薇の花"
romaji = converter.to_roman(text)
print(romaji)  # 出力: "Bara No Hana"

# 外来語を含むテキストの変換
text = "アースウィンド"
romaji = converter.to_roman(text)
print(romaji)  # 出力: "Earth Wind"

外来語辞書のカスタマイズ

外来語の変換は hiragana_english.json ファイルに基づいて行われます。このファイルをカスタマイズすることで、特定の単語の変換方法を調整できます。

{
  "あーす": "earth",
  "どあ": "door",
  "らぶ": "love"
}

使用例

from romann import RomanConverter

converter = RomanConverter()
result = converter.to_roman("こんにちは")
print(result)  # 出力: Konnichiha

関連

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

romann-0.1.0.tar.gz (67.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

romann-0.1.0-py3-none-any.whl (64.0 kB view details)

Uploaded Python 3

File details

Details for the file romann-0.1.0.tar.gz.

File metadata

  • Download URL: romann-0.1.0.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for romann-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f7c083e473337df246a193f45ec799eb1dd36266d48d2c572aec7ef6267ccfe
MD5 460783d769b59a0f9536033b0c208bc2
BLAKE2b-256 9cc966c386317f392e63fb10e97218e674ab2df2f61f1f41b91a1242ac9947bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for romann-0.1.0.tar.gz:

Publisher: pypi-release.yml on kuwa72/romann

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file romann-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: romann-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 64.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for romann-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b6a80a7f20e913d6226b7786a415ee635d4322357cc04b58a0ca014ebbc4b46
MD5 0ae3a53fd9ed93bf6feed0bb9831829b
BLAKE2b-256 6cebd7f1b6a52e1e4e7ec7bab084e45f98184fdf338d8793f4e6466bf91d938b

See more details on using hashes here.

Provenance

The following attestation bundles were made for romann-0.1.0-py3-none-any.whl:

Publisher: pypi-release.yml on kuwa72/romann

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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