POTUS: Flipping out to text template (#3053)
* POTUS: Flipping out to text template * POTUS: Tests should be calling `build_test` :) * POTUS: Test refactormaster
parent
707350bf90
commit
348df8e526
|
@ -37,12 +37,15 @@ handle remainder => sub {
|
|||
my $the_guy = $presidents[$index];
|
||||
my $which = ordinate($num);
|
||||
|
||||
return "$the_guy $fact $which $POTUS.",
|
||||
structured_answer => {
|
||||
input => [$which],
|
||||
operation => $POTUS,
|
||||
result => $the_guy,
|
||||
};
|
||||
return "$the_guy $fact $which $POTUS.", structured_answer => {
|
||||
data => {
|
||||
title => $the_guy,
|
||||
subtitle => "$which $POTUS",
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -8,90 +8,36 @@ use DDG::Test::Goodie;
|
|||
zci answer_type => 'potus';
|
||||
zci is_cached => 1;
|
||||
|
||||
sub build_test
|
||||
{
|
||||
my ($who, $article, $number) = @_;
|
||||
|
||||
return test_zci("$who $article the $number President of the United States.", structured_answer => {
|
||||
data => {
|
||||
title => $who,
|
||||
subtitle => "$number President of the United States"
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::POTUS)],
|
||||
'who is president of the united states' => test_zci(
|
||||
'Barack Obama is the 44th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['44th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Barack Obama'
|
||||
}
|
||||
),
|
||||
'who is the fourth president of the united states' => test_zci(
|
||||
'James Madison was the 4th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['4th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'James Madison'
|
||||
}
|
||||
),
|
||||
'who is the nineteenth president of the united states' => test_zci(
|
||||
'Rutherford B. Hayes was the 19th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['19th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Rutherford B. Hayes'
|
||||
}
|
||||
),
|
||||
'who was the 1st president of the united states' => test_zci(
|
||||
'George Washington was the 1st President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['1st'],
|
||||
operation => 'President of the United States',
|
||||
result => 'George Washington'
|
||||
}
|
||||
),
|
||||
'who was the 31 president of the united states' => test_zci(
|
||||
'Herbert Hoover was the 31st President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['31st'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Herbert Hoover'
|
||||
}
|
||||
),
|
||||
'who was the 22 president of the united states' => test_zci(
|
||||
'Grover Cleveland was the 22nd President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['22nd'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Grover Cleveland'
|
||||
}
|
||||
),
|
||||
'potus 11' => test_zci(
|
||||
'James K. Polk was the 11th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['11th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'James K. Polk'
|
||||
}
|
||||
),
|
||||
'POTUS 24' => test_zci(
|
||||
'Grover Cleveland was the 24th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['24th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Grover Cleveland'
|
||||
}
|
||||
),
|
||||
'who was the twenty-second POTUS?' => test_zci(
|
||||
'Grover Cleveland was the 22nd President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['22nd'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Grover Cleveland'
|
||||
}
|
||||
),
|
||||
'potus 16' => test_zci(
|
||||
'Abraham Lincoln was the 16th President of the United States.',
|
||||
structured_answer => {
|
||||
input => ['16th'],
|
||||
operation => 'President of the United States',
|
||||
result => 'Abraham Lincoln'
|
||||
}
|
||||
),
|
||||
'who is president of the united states' => build_test('Barack Obama', 'is',"44th"),
|
||||
'who is the fourth president of the united states' => build_test('James Madison', 'was', '4th'),
|
||||
'who is the nineteenth president of the united states' => build_test('Rutherford B. Hayes', 'was','19th'),
|
||||
'who was the 1st president of the united states' => build_test('George Washington', 'was', '1st'),
|
||||
'who was the 31 president of the united states' => build_test('Herbert Hoover', 'was', '31st'),
|
||||
'who was the 22 president of the united states' => build_test('Grover Cleveland', 'was','22nd'),
|
||||
'potus 11' => build_test('James K. Polk', 'was','11th'),
|
||||
'POTUS 24' => build_test('Grover Cleveland', 'was', '24th'),
|
||||
'who was the twenty-second POTUS?' => build_test('Grover Cleveland', 'was', '22nd'),
|
||||
'potus 16' => build_test('Abraham Lincoln', 'was', '16th'),
|
||||
'who is the vice president of the united states?' => undef,
|
||||
'vice president of the united states' => undef
|
||||
'vice president of the united states' => undef,
|
||||
'VPOTUS' => undef
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue