Skip to content
This repository
Newer
Older
100644 37 lines (26 sloc) 1.193 kb
a37d91bf »
2012-02-29 convert another batch to new API
1 package DDG::Goodie::PercentError;
2
3 use DDG::Goodie;
4
1eb3358c »
2013-06-14 make "%-error" trigger explicit to work w/ new ddg trigger rules
5 triggers start => "percent error", "% error", "%err", "%error", "percenterror", "percent err", "%-error";
a37d91bf »
2012-02-29 convert another batch to new API
6
cbcfc305 »
2012-03-21 apparently i can't read after 10pm
7 zci answer_type => "percent_error";
d760e759 »
2012-03-20 CamelCase to answer_type and update tests with regexp
8 zci is_cached => 1;
a37d91bf »
2012-02-29 convert another batch to new API
9
1bf6bd3b »
2012-11-06 added metadata to PercentError.pm
10 primary_example_queries 'percent-error 34.5 35';
11 secondary_example_queries '%err 41 43', '%-error 2.88 2.82';
12 description 'find the percent error given accepted and experimental values';
13 name 'PercentError';
14 code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/PercentError.pm';
15 category 'calculations';
16 topics 'math';
17 attribution twitter => 'crazedpsyc',
18 cpan => 'CRZEDPSYC' ;
19
9d72a38d »
2012-05-24 Cleanup, adding multiword trigger, checking for html encoded requirem…
20 handle remainder => sub {
21 my $length = length($_);
17b5ef6c »
2012-05-23 fix percenterror
22 #return unless $length == 2;
a37d91bf »
2012-02-29 convert another batch to new API
23
8c072f93 »
2012-05-29 let percenterror handle lists without spaces
24 my ( $acc, $exp ) = split /\s*[\s;,]\s*/, $_;
f9c9ecb1 »
2012-03-22 fix argument validation
25 return unless $acc =~ /^-?\d+?(?:\.\d+|)$/ && $exp =~ /^-?\d+?(?:\.\d+|)$/;
a37d91bf »
2012-02-29 convert another batch to new API
26
27 my $diff = abs $acc - $exp;
2804bc9a »
2012-03-22 update percent-error to pass tests
28 my $per = abs ($diff/$acc);
29 my $err = $per*100;
d760e759 »
2012-03-20 CamelCase to answer_type and update tests with regexp
30
2a0592a6 »
2012-04-04 fixed %err links
31 my $html = qq(Accepted: $acc Experimental: $exp Error: <a href="javascript:;" onclick="document.x.q.value='$per';document.x.q.focus();">$err%</a>);
a37d91bf »
2012-02-29 convert another batch to new API
32
d760e759 »
2012-03-20 CamelCase to answer_type and update tests with regexp
33 return "Accepted: $acc Experimental: $exp Error: $err%", html => $html;
a37d91bf »
2012-02-29 convert another batch to new API
34 };
35
36 1;
Something went wrong with that request. Please try again.