Add support for additional 'opposite' forms

* Complementary
* Can use 'for|of|to'
master
Ben Moon 2016-07-05 15:21:36 +01:00
parent 51d1294bcc
commit 88317a6394
2 changed files with 10 additions and 3 deletions

View File

@ -16,7 +16,8 @@ zci answer_type => 'rgb_color';
zci is_cached => 0;
triggers any => 'color', 'colour', 'mix', 'opposite';
my @opposite_words = ('opposite', 'complement', 'complementary');
triggers any => 'color', 'colour', 'mix', @opposite_words;
#####################
# Color Constants #
@ -70,11 +71,13 @@ sub probably_relevant {
# Query Handlers #
####################
my $reverse_re = "(opposite|complement(ary)?)( $scolor)?( (of|to|for))?";
my %query_cat = (
random => "rand(om)? $scolor( between (?<c1>$color_re)( and)? " .
"(?<c2>$color_re))?\$",
mix => "mix (?<c1>$color_re)( and)? (?<c2>$color_re)",
reverse => "opposite( of)? (?<c>$color_re)",
reverse => "$reverse_re (?<c>$color_re)",
);
my %query_forms = (
$query_cat{mix} => \&mix_colors,

View File

@ -181,7 +181,10 @@ ddg_goodie_test(
# # Using names
'mix black and white' => $tc_mix_black_white,
# Reversing colors
'opposite of white' => $tc_opp_white,
'opposite of white' => $tc_opp_white,
'complementary color of white' => $tc_opp_white,
'complement white' => $tc_opp_white,
'opposite color for white' => $tc_opp_white,
# Sample queries (from checking query suggestions)
'mix pink and blue what color do you get' => $tc_mix_pink_blue,
'what do you get if you mix blue and orange' => $tc_mix_blue_orange,
@ -200,6 +203,7 @@ ddg_goodie_test(
'opposite of blue raining jane lyrics' => undef,
'pictures of blue rain' => undef,
'blue hex color' => undef,
'complement girl' => undef,
# # With potential to trigger in the future
'blue and gold' => undef,