DuckDuckGo: expand trigger-space.

- Add "duck duck go" trigger.
- Add possessive versions of triggers.
- Allow triggers to appear anywhere in the query.
- Skip prepositions and definite articles before key conversion.

Fixes #645.
master
Matt Miller 2014-09-20 09:48:18 -04:00
parent 5d5c594795
commit 31bfb73a45
2 changed files with 31 additions and 2 deletions

View File

@ -15,7 +15,9 @@ topics 'everyday';
attribution twitter => 'crazedpsyc',
cpan => 'CRZEDPSYC';
triggers startend => "duckduckgo", "ddg", "zeroclickinfo";
my @ddg_aliases = map { ($_, $_ . "'s", $_ . "s") } ('duckduckgo', 'ddg', 'duck duck go');
triggers any => @ddg_aliases, "zeroclickinfo";
zci is_cached => 1;
@ -53,10 +55,14 @@ foreach my $keyword (keys %$responses) {
}
}
my $skip_words_re = qr/\b(?:of|for|the)\b/;
handle remainder => sub {
s/\W+//g;
my $key = lc;
$key =~ s/$skip_words_re//g;
$key =~ s/\W+//g;
my $response = $responses->{$key};
return unless ($response);

View File

@ -37,6 +37,29 @@ ddg_goodie_test([qw(
html =>
"DuckDuckGo's official IRC channel is <a href='http://webchat.freenode.net/?channels=duckduckgo'>#duckduckgo</a> on <a href='http://freenode.net/'>irc.freenode.net</a>"
),
'short URL for duck duck go' =>
test_zci("DuckDuckGo's short URL: http://ddg.gg/", html => "DuckDuckGo's short URL: <a href='http://ddg.gg/'>http://ddg.gg/</a>."),
'xmpp of ddg' => test_zci(
"DuckDuckGo's XMPP service: https://duck.co/blog/using-pidgin-with-xmpp-jabber",
html => "DuckDuckGo's <a href='https://duck.co/blog/using-pidgin-with-xmpp-jabber'>XMPP service</a>."
),
"duckduckgo's about" => test_zci(
"DuckDuckGo's about page: https://duckduckgo.com/about", html => "DuckDuckGo's <a href='https://duckduckgo.com/about'>about page</a>."
),
'duck duck go merchandise' => test_zci(
"Thanks for the support! Check out the DuckDuckGo store for t-shirts, stickers, and other items: https://duck.co/help/community/swag",
html =>
"Thanks for the support! Check out the <a href='https://duck.co/help/community/swag'>DuckDuckGo store</a> for t-shirts, stickers, and other items."
),
"ddgs irc" => test_zci(
"DuckDuckGo's official IRC channel is #duckduckgo on irc.freenode.net.",
html =>
"DuckDuckGo's official IRC channel is <a href='http://webchat.freenode.net/?channels=duckduckgo'>#duckduckgo</a> on <a href='http://freenode.net/'>irc.freenode.net</a>"
),
"the duckduckgo blog" =>
test_zci("DuckDuckGo's official blog: https://duck.co/blog", html => "DuckDuckGo's <a href='https://duck.co/blog'>official blog</a>."),
'the short url of duck duck go' =>
test_zci("DuckDuckGo's short URL: http://ddg.gg/", html => "DuckDuckGo's short URL: <a href='http://ddg.gg/'>http://ddg.gg/</a>."),
irc => undef,
);