Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Japanese to romaji converter in Python

License

NotificationsYou must be signed in to change notification settings

polm/cutlet

Repository files navigation

Open in StreamlitCurrent PyPI packages

cutlet

cutlet by Irasutoya

Cutlet is a tool to convert Japanese to romaji. Check out theinteractive demo! Also see thedocs and theoriginal blog post.

issueを英語で書く必要はありません。

Features:

  • support forModified Hepburn,Kunreisiki,Nihonsiki systems
  • custom overrides for individual mappings
  • custom overrides for specific words
  • built in exceptions list (Tokyo, Osaka, etc.)
  • uses foreign spelling when available in UniDic
  • proper nouns are capitalized
  • slug mode for url generation

Things not supported:

  • traditional Hepburn n-to-m: Shimbashi
  • macrons or circumflexes: Tōkyō, Tôkyô
  • passport Hepburn: Satoh (but you can use an exception)
  • hyphenating words
  • Traditional Hepburn in general is not supported

Internally, cutlet usesfugashi, so you canuse the same dictionary you use for normal tokenization.

Installation

Cutlet can be installed through pip as usual.

pip install cutlet

Note that if you don't have a MeCab dictionary installed you'll also have toinstall one. If you're just getting startedunidic-lite is a good choice.

pip install unidic-lite

Usage

A command-line script is included for quick testing. Just usecutlet and eachline of stdin will be treated as a sentence. You can specify the system to use(hepburn,kunrei,nippon, ornihon) as the first argument.

$ cutletローマ字変換プログラム作ってみた。Roma ji henkan program tsukutte mita.

In code:

importcutletkatsu=cutlet.Cutlet()katsu.romaji("カツカレーは美味しい")# => 'Cutlet curry wa oishii'# you can print a slug suitable for urlskatsu.slug("カツカレーは美味しい")# => 'cutlet-curry-wa-oishii'# You can disable using foreign spelling tookatsu.use_foreign_spelling=Falsekatsu.romaji("カツカレーは美味しい")# => 'Katsu karee wa oishii'# kunreisiki, nihonsiki work tookatu=cutlet.Cutlet('kunrei')katu.romaji("富士山")# => 'Huzi yama'# comparisonnkatu=cutlet.Cutlet('nihon')sent="彼女は王への手紙を読み上げた。"katsu.romaji(sent)# => 'Kanojo wa ou e no tegami wo yomiageta.'katu.romaji(sent)# => 'Kanozyo wa ou e no tegami o yomiageta.'nkatu.romaji(sent)# => 'Kanozyo ha ou he no tegami wo yomiageta.'

Alternatives

  • kakasi: Historically important, but not updated since 2014.
  • pykakasi: self contained, it does segmentation on its own and uses its own dictionary.

[8]ページ先頭

©2009-2025 Movatter.jp