Dewey: Tests passing again; slight renaming

master
Rob 2016-07-02 23:36:54 +01:00
parent 672ebc04e1
commit b83db4c7c8
2 changed files with 16 additions and 9 deletions

View File

@ -46,7 +46,7 @@ handle remainder => sub {
# words that might describe the category
my $word = $3;
#output rows
my $data = {};
my $output = {};
if (defined $word) {
return if lc($word) eq 'system'; # don't respond to "dewey decimal system"
@ -56,11 +56,11 @@ handle remainder => sub {
return unless @results;
if (@results > 1) {
line($types{$_}, $data) for @results;
line($types{$_}, $output) for @results;
$multi = 1;
} else {
my $num = $types{$results[0]};
line($num, $data);
line($num, $output);
}
}
@ -68,21 +68,21 @@ handle remainder => sub {
$_ = sprintf "%03d", $_;
unless ($multi) {
line($_, $data);
line($_, $output);
}
elsif (/\d00/) {
for ($_..$_+99) {
line($_, $data) or next;
line($_, $output) or next;
}
}
elsif (/\d\d0/) {
for ($_..$_+9) {
line($_, $data) or next;
line($_, $output) or next;
}
}
}
return $data, structured_answer => {
return $output, structured_answer => {
id => 'dewey_decimal',
name => 'Answer',
templates => {
@ -94,7 +94,7 @@ handle remainder => sub {
},
data => {
title => 'Dewey Decimal System',
record_data => $data
record_data => $output
}
};
};

View File

@ -57,7 +57,14 @@ ddg_goodie_test(
"146" => "Naturalism and related systems"
})),
'etymology in the dewey decimal system' => test_zci(build_structured_answer({
"412" => "Etymology"
"412" => "Etymology",
"422" => "English etymology",
"432" => "German etymology",
"442" => "French etymology",
"452" => "Italian etymology",
"462" => "Spanish etymology",
"472" => "Classical Latin etymology & phonology",
"482" => "Classical Greek etymology"
})),
'dewey 644' => test_zci(build_structured_answer({
"644" => "Household utilities"