Add some basic custom stop words

'make', 'makes', 'paint', and 'paints'; just some common words that pop
up in queries relating to color.
master
Ben Moon 2016-07-05 21:34:23 +01:00
parent 76495ed45a
commit 9675e8edb1
2 changed files with 8 additions and 2 deletions

View File

@ -20,7 +20,7 @@ zci is_cached => 0;
my @opposite_words = ('opposite', 'complement', 'complementary');
my @color_words = map { $_, "${_}s" } ('color', 'colour');
my @mix_words = ('mix', 'mixed');
my @mix_words = ('mix', 'mixed', 'mixing');
triggers any => @color_words, @mix_words, @opposite_words;
#####################
@ -46,8 +46,13 @@ my $color_name_re = '(?:' .
my $scolor = 'colou?rs?';
my $color_re = "(?:$color_name_re|#?\\p{XDigit}{6})";
# Some stop words relevant to color queries.
my @custom_stops = (
'make', 'makes',
'paint', 'paints',
);
my %stops = (%StopWords, %{getStopWords('en')});
my @stopwords = keys %stops;
my @stopwords = (keys %stops, @custom_stops);
my $stop_re = '(?:' . (join '|', map { quotemeta $_ } @stopwords) . ')';
my $black = Color::Library->color('black');

View File

@ -223,6 +223,7 @@ ddg_goodie_test(
'what do you get if you mix blue and orange' => $tc_mix_blue_orange,
"what's opposite of blue on the color wheel" => $tc_opp_blue,
'mixing blue and orange makes what color' => $tc_mix_blue_orange,
'mixing blue and orange makes what' => $tc_mix_blue_orange,
# Invalid queries
'color' => undef,
'color ffffff' => undef,