Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Expanded Frequency trigger

added letters|characters|chars
  • Loading branch information...
commit fb63a8c150a5b3f48fcc8335cf9febbfc48a1840 1 parent 89c636c
@nospampleasemam nospampleasemam authored
Showing with 11 additions and 8 deletions.
  1. +2 −2 lib/DDG/Goodie/Frequency.pm
  2. +9 −6 t/Frequency.t
View
4 lib/DDG/Goodie/Frequency.pm
@@ -6,7 +6,7 @@ use DDG::Goodie;
triggers start => 'frequency', 'freq';
handle remainder => sub {
- if ($_ =~ /^of ([a-z]|all) in (.*)/i)
+ if ($_ =~ /^of ([a-z]|all(?: (?:letters|characters|chars))?) in (.+)/i)
{
my $collect = lc $1;
my $target_str = lc $2;
@@ -33,7 +33,7 @@ handle remainder => sub {
push @out, join ":", $key, $freq{$key} . "/" . $count;
};
- return "FREQUENCY: " . join ' ',sort(@out) if @out;
+ return "Frequency: " . join ' ',sort(@out) if @out;
};
return;
View
15 t/Frequency.t
@@ -12,12 +12,15 @@ ddg_goodie_test(
[qw(
DDG::Goodie::Frequency
)],
- 'frequency of all in test' => test_zci('FREQUENCY: e:1/4 s:1/4 t:2/4'),
- 'frequency of all in testing 1234 ABC!' => test_zci('FREQUENCY: a:1/10 b:1/10 c:1/10 e:1/10 g:1/10 i:1/10 n:1/10 s:1/10 t:2/10'),
- 'frequency of all in Assassins!' => test_zci('FREQUENCY: a:2/9 i:1/9 n:1/9 s:5/9'),
- 'frequency of a in Atlantic Ocean' => test_zci('FREQUENCY: a:3/13'),
- 'freq of B in battle' => test_zci('FREQUENCY: b:1/6'),
- 'freq of s in Spoons' => test_zci('FREQUENCY: s:2/6'),
+ 'frequency of all in test' => test_zci('Frequency: e:1/4 s:1/4 t:2/4'),
+ 'frequency of all letters in test' => test_zci('Frequency: e:1/4 s:1/4 t:2/4'),
+ 'frequency of all characters in test' => test_zci('Frequency: e:1/4 s:1/4 t:2/4'),
+ 'frequency of all chars in test' => test_zci('Frequency: e:1/4 s:1/4 t:2/4'),
+ 'frequency of all in testing 1234 ABC!' => test_zci('Frequency: a:1/10 b:1/10 c:1/10 e:1/10 g:1/10 i:1/10 n:1/10 s:1/10 t:2/10'),
+ 'frequency of all in Assassins!' => test_zci('Frequency: a:2/9 i:1/9 n:1/9 s:5/9'),
+ 'frequency of a in Atlantic Ocean' => test_zci('Frequency: a:3/13'),
+ 'freq of B in battle' => test_zci('Frequency: b:1/6'),
+ 'freq of s in Spoons' => test_zci('Frequency: s:2/6'),
);
Please sign in to comment.
Something went wrong with that request. Please try again.