Lingua::ZH::PinyinConvert::ID - Convert between various Chinese pinyin system and Indonesian transliteration
version 0.04
use Lingua::ZH::PinyinConvert::ID; my $conv = Lingua::ZH::PinyinConvert::ID; # convert Hanyu pinyin to Indonesian transliteration my $id = $conv->hanyu2id("zhongwen"); # "cungwen" $id = $conv->hanyu2id("zhong1 wen2"); # "cung1 wen2" $id = $conv->hanyu2id("zhong1 wen2", {remove_tones=>1}); # "cung wen" # convert Jyutping (cantonese) to Indonesian transliteration my $id = $conv->jyutping2id("zungman"); # "cungman" # convert Indonesian transliteration to Hanyu pinyin, if # possible. if ambiguous, then will return undef. my $hanyu = $conv->id2hanyu("i sheng"); # "yi sheng" $hanyu = $conv->id2hanyu("ce"); # undef, ambiguous between ze/zhe/zhi/zi $hanyu = $conv->id2hanyu("ce", {list_all=>1}); "(ze|zhe|zhi|zi)" # convert Indonesian transliteration to Jyutping. my $jyutping = $conv->id2jyutping("ying man"); # "jing man" # detect pinyin or Indonesian transliteration in text. return a # list of 0 or more elements, each element being "hanyu", # "jyutping", "id-mandarin", or "id-cantonese". print join ", ", $conv->detect("I love You"); # "" print join ", ", $conv->detect("wo de xin"); # "hanyu" print join ", ", $conv->detect("wo te sin"); # "jyutping", "id-mandarin", "id-cantonese"
This module converts between various Chinese pinyin systems and Indonesian transliteration. Currently these pinyin systems are supported: Hanyu Pinyin (Mandarin) and Jyutping (Cantonese).
Indonesian transliteration is admittedly non-standardized and inaccurate, and more and more people are learning Hanyu Pinyin each day, but it is still useful for those who are unfamiliar with Pinyin systems. You can still encounter Indonesian transliteration in some places, e.g. Karaoke video subtitles or old textbooks.
Create a new instance. Currently there are no known options.
Convert Hanyu pinyin to Indonesian transliteration. Pinyins are expected to be written in lowercase. Unknown characters will just be returned as-is.
$opts is an optional hahref containing options. Known options:
$opts
remove_tones => BOOL
If true, tone numbers will be removed.
Convert Jyutping to Indonesian transliteration. Pinyins are expected to be written in lowercase. Unknown characters will just be returned as-is.
Convert Indonesian transliteration to Hanyu pinyin. Pinyins are expected to be written in lowercase. Since Indonesian transliteration can be ambiguous (e.g. Mandarin sounds 'ze', 'zhe', 'zhi', 'zi' are usually all transliterated as 'ce'), conversion is not always possible. When this is the case, undef is returned.
list_all => BOOL
If true, then when conversion is ambiguous, instead of returning undef, all alternatives are returneed.
Convert Indonesian transliteration to Jyutping. Pinyins are expected to be written in lowercase. Since Indonesian transliteration can be ambiguous (e.g. Cantonese sounds 'kwik' and 'gwik' are sometimes all transliterated as 'kwik'), conversion is not always possible. When this is the case, undef is returned.
Detect pinyin or Indonesian transliteration in text. Pinyins are expected to be written in lowercase and separated into words. Return a list of 0 or more elements, each element being "hanyu", "cantonese", "id-mandarin", or "id-cantonese".
Return all Hanyu pinyin syllables.
Return all Jyutping syllables.
Return all Indonesian transliteration syllables for Mandarin.
Return all Indonesian transliteration syllables for Cantonese.
Lingua::ZH::PinyinConvert
Lingua::Han::PinYin
Steven Haryanto <stevenharyanto@gmail.com>
This software is copyright (c) 2013 by Steven Haryanto.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Lingua::ZH::PinyinConvert::ID, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::ZH::PinyinConvert::ID
CPAN shell
perl -MCPAN -e shell install Lingua::ZH::PinyinConvert::ID
For more information on module installation, please visit the detailed CPAN module installation guide.