again
parent
57afc55c16
commit
4daa979b71
|
@ -5,6 +5,19 @@ use List::Util 'shuffle';
|
|||
|
||||
triggers start => "anagram", "anagrams";
|
||||
|
||||
zci is_cached => 0;
|
||||
zci answer_type => "anagram";
|
||||
|
||||
primary_example_queries "anagram of filter";
|
||||
secondary_example_queries "anagram filter 5";
|
||||
description "find the anagram(s) of your query";
|
||||
name "Anagram";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Anagram.pm";
|
||||
category "transformations";
|
||||
topics "words_and_games";
|
||||
|
||||
attribution github => ["https://github.com/beardlybread", "beardlybread"];
|
||||
|
||||
handle remainder => sub {
|
||||
|
||||
s/^of\s(.*)/$1/i;
|
||||
|
@ -55,11 +68,11 @@ handle remainder => sub {
|
|||
}
|
||||
}
|
||||
}
|
||||
# copied verbatim from Anagram.pm
|
||||
# copied verbatim from Randagram.pm
|
||||
my @chars = split(//, $in);
|
||||
@chars = shuffle(@chars);
|
||||
my $garbledAnswer = '"'.$in.'" scrambled: '.join('',@chars);
|
||||
# end Anagram.pm
|
||||
# end Randagram.pm
|
||||
|
||||
if($full_word) {
|
||||
if(@output) {
|
||||
|
@ -73,6 +86,4 @@ handle remainder => sub {
|
|||
return $garbledAnswer;
|
||||
};
|
||||
|
||||
zci is_cached => 0;
|
||||
|
||||
1;
|
||||
|
|
|
@ -6,6 +6,18 @@ use List::Util 'shuffle';
|
|||
|
||||
triggers start => "randagram";
|
||||
|
||||
zci is_cached => 0;
|
||||
zci answer_type => "randagram";
|
||||
|
||||
primary_example_queries "randagram jazz hands";
|
||||
description "mix up the letters of your query";
|
||||
name "Randagram";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Randagram.pm";
|
||||
category "transformations";
|
||||
topics "words_and_games";
|
||||
|
||||
attribution github => ["https://github.com/crazedpsyc", "crazedpsyc"];
|
||||
|
||||
handle remainder => sub {
|
||||
s/^of\s(.*)/$1/i;
|
||||
my @chars = split(//, $_); #convert each character of the query to an array element
|
||||
|
|
|
@ -5,13 +5,13 @@ use warnings;
|
|||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => 'anagramsolver';
|
||||
zci answer_type => 'anagram';
|
||||
zci is_cached => 0;
|
||||
|
||||
# the regexps are kind of a hack, but it seemed better than not testing
|
||||
# it at all
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::AnagramSolver)],
|
||||
[qw(DDG::Goodie::Anagram)],
|
||||
'anagram filter' => test_zci("anagram: trifle"),
|
||||
'anagrams events' => test_zci("anagram: Steven"),
|
||||
'anagram of algorithm' => test_zci("anagram: logarithm"),
|
||||
|
@ -19,7 +19,7 @@ ddg_goodie_test(
|
|||
'anagram of' => test_zci(qr/\"of\" scrambled: (of|fo)/),
|
||||
'anagram filter 5' => test_zci("Anagrams of filter of size 5: filet, flier, flirt, lifer, liter, refit, rifle"),
|
||||
'anagram times' => test_zci("anagrams: emits, items, mites, smite"),
|
||||
'anagram Mixing it up' => test_zci(qr/\"Mixing it up\" garbled: [ Mixngtup]{12}/),
|
||||
'anagram Mixing it up' => test_zci(qr/\"Mixing it up\" scrambled: [ Mixngtup]{12}/),
|
||||
'anagram algorithm 14' => test_zci("anagram: logarithm")
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue