| Lingua-Han-PinYin documentation | view source | Contained in the Lingua-Han-PinYin distribution. |
Lingua::Han::PinYin - Retrieve the Mandarin(PinYin) of Chinese character(HanZi).
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'
There is a Chinese document @ http://www.fayland.org/project/Han-PinYin/. It tells why and how I write this module.
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;
default is 0. if tone is needed, plz set this to 1.
default is 0.
The ascii 'v' is used instead of the unicode 'yu' Since version 0.06.
Fayland Lam, <fayland at gmail.com>
Tong Sun, <suntong at cpan.org>
Copyright (c) 2005-2009 *AUTHORS* All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Lingua-Han-PinYin documentation | view source | Contained in the Lingua-Han-PinYin distribution. |