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("薔薇の花")) # BaraNoHana
print(converter.to_roman("アース・ウィンド&ファイアー")) # EarthWindAndFire
# スペースありの変換(オプション)
print(converter.to_roman("薔薇の花", remove_spaces=False)) # Bara No Hana
print(converter.to_roman("アース・ウィンド&ファイアー", remove_spaces=False)) # Earth Wind & Fire
変換ルール
- 単語の先頭は大文字
- デフォルトではスペースなしで出力(オプションでスペース区切りに変更可能)
- 外来語は辞書にあれば英語表記、なければローマ字
- 記号類はそのまま(「、」「。」は「,」「.」に変換)
- 前後・連続する空白は整理
外来語辞書を引く条件
外来語辞書は**読み(ひらがな)**をキーにするため、読みが偶然一致するだけの語まで 巻き込んでしまう。カタカナ表記そのものが外来語のしるしなので、そこを軸に絞っている。
| トークンの表記 | 辞書を引くか | 例 |
|---|---|---|
| カタカナ | 引く | ドロップス → Drops |
| ひらがな | 名詞・形状詞だけ引く | らぶ → Love / 食べたい(助動詞)→ Tai |
| 漢字・ラテン文字を含む | 引かない | 愛 → Ai(I ではない)/ Vol. → Vol.(Volume ではない) |
| 記号 | 引く | & → And |
外来語辞書のカスタマイズ
外来語の変換は hiragana_english.json に基づきます。これを編集することで、
特定単語の変換方法を調整できます。キーは読みのひらがな、値は小文字の英語表記。
{
"あーす": "earth",
"どあ": "door",
"どろっぷす": "drops"
}
値を空文字にすると語ごと消えてしまうので、必ず何か入れること。
漢字語は kanji_english.json に表記そのものをキーにして入れます。
読みで引かないので衝突しません。英語のつづりが定まっている固有名詞だけを入れること。
{
"東京": "tokyo"
}
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
# 複数単語の変換(デフォルトでスペースなし)
result = converter.to_roman("こんにちは 世界")
print(result) # 出力: KonnichihaSekai
# スペースありの変換
result = converter.to_roman("こんにちは 世界", remove_spaces=False)
print(result) # 出力: Konnichiha Sekai
関連
Release files for romann 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| romann-0.2.0.tar.gz | 80.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| romann-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.8 kB
Release files / romann-0.2.0.tar.gz
| Download URL | romann-0.2.0.tar.gz |
|---|---|
| Size | 80.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56132fce47a665df61106de15f27d951a14c26c791601c6be3287d35308161ce
|
|
BLAKE2b-256 checksum How to use checksums |
eccd8413890aeb431fec9b9ff9e7649b16d2089118be560b7c585dbc61dc9937
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / romann-0.2.0-py3-none-any.whl
| Download URL | romann-0.2.0-py3-none-any.whl |
|---|---|
| Size | 74.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b072a5c0c68902df0085ba8078a67bb6c810cea74ea4ee29cac9237a4c5358f
|
|
BLAKE2b-256 checksum How to use checksums |
c281f4b81ee7aeded3bc98bb931d17140e88519160ba756f76db190218d68519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency log