Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).


Lingua-Han-PinYin documentation  | view source Contained in the Lingua-Han-PinYin distribution.

Index


NAME

Top

Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).

SYNOPSIS

Top

  use Lingua::Han::PinYin;

  my $h2p = new Lingua::Han::PinYin();

  # han2pinyin
  print $h2p->han2pinyin("我"); # wo
  my @result = $h2p->han2pinyin("爱你"); # @result = ('ai', 'ni');

  # if you are sure to pass 1 Chinese letter at a time, han2pinyin1 is faster
  print $h2p->han2pinyin1("我"); # wo
  # if you are sure your encoding is GB2312, gb2pinyin is faster
  print $h2p->gb2pinyin("I love (汉语)拼—音 Ah"); # I love (hanyu)pin—yin Ah

  # we can set the tone up
  my $h2p = new Lingua::Han::PinYin(tone => 1);
  print $h2p->han2pinyin("我"); #wo3
  my @result = $h2p->han2pinyin("爱你"); # @result = ('ai4', 'ni3');
  print $h2p->han2pinyin("林道"); #lin2dao4
  print $h2p->han2pinyin("I love 余瑞华 a"); #i love yuruihua a

  # for polyphone(duoyinzi)
  my $h2p = new Lingua::Han::PinYin(duoyinzi => 1, tone => 1);
  print $h2p->han2pinyin("行"); # 'xing2 hang2 xing4 hang4 heng2'

DESCRIPTION

Top

There is a Chinese document @ http://www.fayland.org/project/Han-PinYin/. It tells why and how I write this module.

RETURN VALUE

Top

Usually, it returns its pinyin/spell. It includes more than 20,000 words (from Unicode.org Unihan.txt, version 4.1.0).

if not(I mean it's not a Chinese character), returns the original word;

OPTION

Top

tone => 1|0

default is 0. if tone is needed, plz set this to 1.

duoyinzi => 1|0

default is 0.

CAVEAT

Top

The ascii 'v' is used instead of the unicode 'yu' Since version 0.06.

SEE ALSO

Top

Unicode::Unihan

AUTHORS

Top

Fayland Lam, <fayland at gmail.com>

Tong Sun, <suntong at cpan.org>

COPYRIGHT

Top


Lingua-Han-PinYin documentation  | view source Contained in the Lingua-Han-PinYin distribution.