diff --git a/lib/DDG/Goodie/RgbColor.pm b/lib/DDG/Goodie/RgbColor.pm index 7b4f9f695..5e71db165 100644 --- a/lib/DDG/Goodie/RgbColor.pm +++ b/lib/DDG/Goodie/RgbColor.pm @@ -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 (?$color_re)( and)? " . "(?$color_re))?\$", mix => "mix (?$color_re)( and)? (?$color_re)", - reverse => "opposite( of)? (?$color_re)", + reverse => "$reverse_re (?$color_re)", ); my %query_forms = ( $query_cat{mix} => \&mix_colors, diff --git a/t/RgbColor.t b/t/RgbColor.t index 9d143d7bc..62d82d3b5 100644 --- a/t/RgbColor.t +++ b/t/RgbColor.t @@ -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,