The idea is to find all the pronunciations of the word, and then take the first letter.
Code:
while(<DATA>) { Chomp; my($head,$all) = /^(. {3})(.*)$/; $all=~ s/^\s+//; ## # Keep only the first letter of the non-sound label SubToshorter {my $str=$_[0]; $str=~ s/ā|á|ǎ|à/a/G; $str=~ s/ē|é|ě|è/e/G; $str=~ s/ō|ó|ǒ|ò/o/G; $str=~ s/^ ([A-z]). *$/\1/; return $str; }; my @tmp; for(Split ',',$all) { Push @tmp, Toshorter ($_); } $all=Join ',',@tmp; ### $pytable{$head} =$all;}SubGetheadstr {my @str=$_[0] =~ /. {3}/G; my @res; SubLoop {my($no,$head) =@_; for(Split ',',$pytable {$str [$no]}) { if($no== $#str) { Push @res,$head."'.$_; } Else{loop ($no+1,$head."'.$_); }}} loop (0,""); return join ', grep {+ + $count {$_} < 2;} @res;}PrintGETHEADSTR ("Le Yun");__data__The data here is the content of my previous blog postOmitted
Data in this
[Perl] string to Pinyin first letter (support Polyphone)