return if content dont contain Chinese and result don't contain special Pinyin character (e.g. yes3)

master
yhe 2016-07-05 05:20:30 +00:00
parent 31653a7904
commit 93f0a60e53
2 changed files with 9 additions and 0 deletions

View File

@ -97,6 +97,14 @@ handle remainder_lc => sub {
my $result = $h2p->han2pinyin($spacedChineseString);
$result = ConvertTone($result);
# if content dont contain Chinese
if(!(/[\p{Han}]/)){
# and result don't contain special Pinyin character
if ($result !~ m/[āáǎàēéěèīíǐìōóǒòūúǔùǜǘǚǜ]/) {
return;
}
}
return "Pinyin of $_ is \"$result\"",
structured_answer => {
data => {

View File

@ -54,6 +54,7 @@ ddg_goodie_test(
# Try to include some examples of queries on which it might
# appear that your answer will trigger, but does not.
'pinyin ' => undef,
'pinyin yes3' => undef,
'pinyin how are you?' => undef,
'pinyin zhōng guó' => undef,
);