Lingua::JA::Hepburn::Passport - Hepburn Romanization using Japanese passport rules
use utf8; use Lingua::JA::Hepburn::Passport; my $hepburn = Lingua::JA::Hepburn::Passport->new; $hepburn->romanize("みやがわ"); # MIYAGAWA $hepburn->romanize("おおの"); # ONO $hepburn->romanize("かとう"); # KATO $hepburn->romanize("ゆうこ"); # YUKO $hepburn->romanize("なんば"); # NAMBA $hepburn->romanize("はっちょう"); # HATCHO # Indicate long vowels by "h" my $hepburn = Lingua::JA::Hepburn::Passport->new( long_vowels_h => 1 ); $hepburn->romanize("おおの"); # OHNO $hepburn->romanize("かとう"); # KATOH
Lingua::JA::Hepburn::Passport is a Hiragana/Katakana to Romanization engine using Japanese passport rules.
There is already a couple of Hepburn romanization modules on CPAN (See "SEE ALSO"), but none of them conform to the conversion rule defined in Japanese passport regulation. This one does.
$hepburn = Lingua::JA::Hepburn::Passport->new; $hepburn = Lingua::JA::Hepburn::Passport->new( long_vowels_h => 1 );
Creates a new object. Optionally you can pass long_vowels_h parameter to 1, with which this module tries to add H to the long vowels OO and OU, as allowed in Japanese passport rules.
$roman = $hepburn->romanize( $kana );
Romanizes the string $kana using Hepburn romanization. $kana should be either Hiragana or Katakana, as an Unicode string in Perl (a.k.a UTF-8 flagged), otherwise it throws an error. Returned $roman would be all upper case roman letters.
This module doesn't come with deromanize method (yet), which would do the Roman to Katakana/Hiragana translation, since I don't think we need it. Other modules on CPAN already do the job quite nicely.
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Code algorithm is based on http://www.d-project.com/hebonconv/
http://www.seikatubunka.metro.tokyo.jp/hebon/, http://en.wikipedia.org/wiki/Hepburn_romanization, Lingua::JA::Romanize::Kana, Lingua::JA::Kana
To install Lingua::JA::Hepburn::Passport, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::JA::Hepburn::Passport
CPAN shell
perl -MCPAN -e shell install Lingua::JA::Hepburn::Passport
For more information on module installation, please visit the detailed CPAN module installation guide.