Remove periods from titles, subtitles and plaintext responses (#3569)
* Remove periods from titles, subtitles and plaintext responses * Update test files * Remove concatenation * Remove repeated tests from Cusip test filemaster
parent
85dfac253e
commit
51dafeaa31
|
@ -26,9 +26,9 @@ handle remainder => sub {
|
|||
my ($output, $htmlOutput);
|
||||
|
||||
if ($cusip->is_valid) {
|
||||
$output = "$_ is a properly formatted CUSIP number.";
|
||||
$output = "$_ is a properly formatted CUSIP number";
|
||||
} else {
|
||||
$output = "$_ is not a properly formatted CUSIP number.";
|
||||
$output = "$_ is not a properly formatted CUSIP number";
|
||||
}
|
||||
|
||||
# output results
|
||||
|
|
|
@ -40,7 +40,7 @@ handle remainder => sub {
|
|||
my $startDate = date_output_string($date1);
|
||||
my $endDate = date_output_string($date2);
|
||||
|
||||
return "There are $daysBetween days between $startDate and $endDate$inclusive.",
|
||||
return "There are $daysBetween days between $startDate and $endDate$inclusive",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $daysBetween,
|
||||
|
|
|
@ -27,7 +27,7 @@ handle remainder => sub {
|
|||
|
||||
my $result = Math::BigInt::bgcd(@numbers);
|
||||
|
||||
return "Greatest common factor of $formatted_numbers is $result.",
|
||||
return "Greatest common factor of $formatted_numbers is $result",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => "$result",
|
||||
|
|
|
@ -37,7 +37,7 @@ handle remainder => sub {
|
|||
my $the_guy = $presidents[$index];
|
||||
my $which = ordinate($num);
|
||||
|
||||
return "$the_guy $fact $which $POTUS.", structured_answer => {
|
||||
return "$the_guy $fact $which $POTUS", structured_answer => {
|
||||
data => {
|
||||
title => $the_guy,
|
||||
subtitle => "$which $POTUS",
|
||||
|
|
|
@ -61,7 +61,7 @@ handle query_raw => sub {
|
|||
#U+2126 is the ohm symbol, U+00B1 is the plus-minus sign.
|
||||
my $title = "$resistance $append\x{2126} \x{00B1} $marginE\%";
|
||||
my $subtitle = "Resistance of $_ resistor";
|
||||
my $answer = "A $_ resistor has a resistance of $title.";
|
||||
my $answer = "A $_ resistor has a resistance of $title";
|
||||
|
||||
return $answer,
|
||||
structured_answer => {
|
||||
|
|
|
@ -108,7 +108,7 @@ sub pretty_output {
|
|||
$rise =~ s/^\s+//g; # strftime puts a space in front for single-digits.
|
||||
$set =~ s/^\s+//g;
|
||||
|
||||
my $text = "On $when, sunrise in $where is at $rise; sunset at $set.";
|
||||
my $text = "On $when, sunrise in $where is at $rise; sunset at $set";
|
||||
|
||||
return $text,
|
||||
structured_answer => {
|
||||
|
|
|
@ -40,7 +40,8 @@ handle query => sub {
|
|||
# If they guessed, we need to answer the question they asked.
|
||||
$guess_result = (!$guess) ? '' : ($guess eq $to_show) ? 'Yes, ' : 'No, ';
|
||||
}
|
||||
my $answer = $guess_result . '12:00' . $meridian . ' is ' . $to_show . '.';
|
||||
|
||||
my $answer = "${guess_result}12:00$meridian is $to_show";
|
||||
|
||||
return $answer, structured_answer => {
|
||||
data => {
|
||||
|
|
|
@ -63,7 +63,7 @@ handle query_lc => sub {
|
|||
# Asking about current week of the current year
|
||||
if ($week eq 'current' and $year eq 'current') {
|
||||
my ($dt_week_num, $dt_year) = (ordinate($dt->week_number), $dt->year);
|
||||
$response = "We are currently in the $dt_week_num week of $dt_year.";
|
||||
$response = "We are currently in the $dt_week_num week of $dt_year";
|
||||
}
|
||||
# Asking about nth week of the current year
|
||||
elsif ($year eq 'current') {
|
||||
|
@ -78,7 +78,7 @@ handle query_lc => sub {
|
|||
|
||||
$start_term = "began" if ($year < $dt->year || $year == $dt->year && ($week< $dt->week && $day < $dt->day));
|
||||
|
||||
$response = "The $week_num week of $year $start_term on $out_month $day_num.";
|
||||
$response = "The $week_num week of $year $start_term on $out_month $day_num";
|
||||
}
|
||||
|
||||
return $response, structured_answer => {
|
||||
|
|
|
@ -29,7 +29,7 @@ handle remainder => sub {
|
|||
my $verb = $weekday_count == 1 ? 'is' : 'are';
|
||||
my $weekday_plurality = $weekday_count == 1 ? 'Weekday' : 'Weekdays';
|
||||
|
||||
my $response = "There $verb $weekday_count $weekday_plurality between $start_str and $end_str.";
|
||||
my $response = "There $verb $weekday_count $weekday_plurality between $start_str and $end_str";
|
||||
|
||||
return $response,
|
||||
structured_answer => {
|
||||
|
|
|
@ -57,11 +57,11 @@ handle query_lc => sub {
|
|||
|
||||
my $massUnit = $mass_input.$unit;
|
||||
|
||||
return "Weight of a $massUnit mass on Earth is ${weight}N.",
|
||||
return "Weight of a $massUnit mass on Earth is ${weight}N",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => "Weight of a $massUnit ${conversiontext}mass on Earth is ${weight}N.",
|
||||
subtitle => "Taking value of acceleration due to gravity on Earth as ".g."m/s^2."
|
||||
title => "Weight of a $massUnit ${conversiontext}mass on Earth is ${weight}N",
|
||||
subtitle => "Taking value of acceleration due to gravity on Earth as ".g."m/s^2"
|
||||
},
|
||||
templates => {
|
||||
group => "text"
|
||||
|
|
|
@ -36,7 +36,7 @@ handle remainder => sub {
|
|||
my $verb = $workdays == 1 ? 'is' : 'are';
|
||||
my $number = $workdays == 1 ? 'Workday' : 'Workdays';
|
||||
|
||||
return "There $verb $workdays $number between $start_str and $end_str.",
|
||||
return "There $verb $workdays $number between $start_str and $end_str",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $workdays,
|
||||
|
|
352
t/Cusip.t
352
t/Cusip.t
|
@ -8,9 +8,82 @@ use DDG::Test::Goodie;
|
|||
|
||||
zci answer_type => "cusip";
|
||||
|
||||
|
||||
sub build_test {
|
||||
|
||||
my $title = shift;
|
||||
return test_zci(
|
||||
$title,
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $title,
|
||||
},
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ddg_goodie_test(
|
||||
['DDG::Goodie::Cusip'],
|
||||
|
||||
#####
|
||||
# triggers that SHOULD load the IA
|
||||
|
||||
# typical well-formed queries for AAPL and Southwest
|
||||
'cusip 037833100' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
'cusip check 037833100' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
'cusip 844741108' => build_test('844741108 is a properly formatted CUSIP number'),
|
||||
'037833100 cusip' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
'037833100 cusip check' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
|
||||
# starting white space should be stripped
|
||||
'cusip 037833100' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
|
||||
# ending white space should be stripped
|
||||
'cusip 037833100 ' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
|
||||
# starting and ending white space should be stripped
|
||||
'cusip 037833100 ' => build_test('037833100 is a properly formatted CUSIP number'),
|
||||
|
||||
# same AAPL queries with an incorrect check digit
|
||||
'cusip 03783310A' => build_test('03783310A is not a properly formatted CUSIP number'),
|
||||
'cusip 03783310A' => build_test('03783310A is not a properly formatted CUSIP number'),
|
||||
'cusip 03783310A ' => build_test('03783310A is not a properly formatted CUSIP number'),
|
||||
'cusip 03783310A ' => build_test('03783310A is not a properly formatted CUSIP number'),
|
||||
|
||||
# check CUSIP IDs with capital letters (these are for GOOG and Blackberry)
|
||||
'cusip 38259P706' => build_test('38259P706 is a properly formatted CUSIP number'),
|
||||
'cusip 38259P508' => build_test('38259P508 is a properly formatted CUSIP number'),
|
||||
'cusip 09228F103' => build_test('09228F103 is a properly formatted CUSIP number'),
|
||||
|
||||
# check the same CUSIP IDs with lower case letters
|
||||
'cusip 38259p706' => build_test('38259P706 is a properly formatted CUSIP number'),
|
||||
'cusip 38259p508' => build_test('38259P508 is a properly formatted CUSIP number'),
|
||||
'cusip 09228f103' => build_test('09228F103 is a properly formatted CUSIP number'),
|
||||
|
||||
# check CUSIP IDs with '*', '#', and '@'
|
||||
# these CUSIP ID check digits were calculated by hand
|
||||
# if possible, these tests should be replaced with verified CUSIP IDs
|
||||
'cusip 037833*00' => build_test('037833*00 is not a properly formatted CUSIP number'),
|
||||
'cusip 037833*02' => build_test('037833*02 is a properly formatted CUSIP number'),
|
||||
'cusip 0378331#0' => build_test('0378331#0 is not a properly formatted CUSIP number'),
|
||||
'cusip 0378331#7' => build_test('0378331#7 is a properly formatted CUSIP number'),
|
||||
'cusip 037833@00' => build_test('037833@00 is not a properly formatted CUSIP number'),
|
||||
'cusip 037833@01' => build_test('037833@01 is a properly formatted CUSIP number'),
|
||||
|
||||
# CUSIP IDs ending in '*', '#', and '@' should not break the IA
|
||||
# even though they are always invalid IDs
|
||||
'cusip 03783310*' => build_test('03783310* is not a properly formatted CUSIP number'),
|
||||
'cusip 03783310#' => build_test('03783310# is not a properly formatted CUSIP number'),
|
||||
'cusip 03783310@' => build_test('03783310@ is not a properly formatted CUSIP number'),
|
||||
|
||||
# Odd CUSIP IDs should not break the IA
|
||||
'cusip ********8' => build_test('********8 is not a properly formatted CUSIP number'),
|
||||
'cusip ########9' => build_test('########9 is not a properly formatted CUSIP number'),
|
||||
'cusip @#*@#*@#*' => build_test('@#*@#*@#* is not a properly formatted CUSIP number'),
|
||||
|
||||
#####
|
||||
# triggers that SHOULD NOT load the IA
|
||||
|
||||
|
@ -36,278 +109,9 @@ ddg_goodie_test(
|
|||
|
||||
# multiple IDs are not currently checked
|
||||
'cusip 037833100 037833100' => undef,
|
||||
'cusip 037833100 12345' => undef,
|
||||
'cusip 12345 037833100' => undef,
|
||||
'cusip 01234 56789' => undef,
|
||||
'cusip 037833100 12345' => undef,
|
||||
'cusip 12345 037833100' => undef,
|
||||
'cusip 01234 56789' => undef,
|
||||
);
|
||||
|
||||
#####
|
||||
# triggers that SHOULD load the IA
|
||||
|
||||
# typical well-formed queries for AAPL and Southwest
|
||||
'cusip 037833100' => test_zci(
|
||||
"037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => "037833100 is a properly formatted CUSIP number.",
|
||||
},
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip check 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 844741108' => test_zci("844741108 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'037833100 cusip' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'037833100 cusip check' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# starting white space should be stripped
|
||||
'cusip 037833100' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# ending white space should be stripped
|
||||
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# starting and ending white space should be stripped
|
||||
'cusip 037833100 ' => test_zci("037833100 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# same AAPL queries with an incorrect check digit
|
||||
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 03783310A' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 03783310A ' => test_zci("03783310A is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# check CUSIP IDs with capital letters (these are for GOOG and Blackberry)
|
||||
'cusip 38259P706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 38259P508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 09228F103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# check the same CUSIP IDs with lower case letters
|
||||
'cusip 38259p706' => test_zci("38259P706 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 38259p508' => test_zci("38259P508 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 09228f103' => test_zci("09228F103 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# check CUSIP IDs with '*', '#', and '@'
|
||||
# these CUSIP ID check digits were calculated by hand
|
||||
# if possible, these tests should be replaced with verified CUSIP IDs
|
||||
'cusip 037833*00' => test_zci("037833*00 is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 037833*02' => test_zci("037833*02 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 0378331#0' => test_zci("0378331#0 is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 0378331#7' => test_zci("0378331#7 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 037833@00' => test_zci("037833\@00 is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 037833@01' => test_zci("037833\@01 is a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# CUSIP IDs ending in '*', '#', and '@' should not break the IA
|
||||
# even though they are always invalid IDs
|
||||
'cusip 03783310*' => test_zci("03783310* is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 03783310#' => test_zci("03783310# is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip 03783310@' => test_zci("03783310\@ is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
# Odd CUSIP IDs should not break the IA
|
||||
'cusip ********8' => test_zci("********8 is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip ########9' => test_zci("########9 is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
'cusip @#*@#*@#*' => test_zci("\@#*\@#*\@#* is not a properly formatted CUSIP number.",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
group => 'text',
|
||||
}
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
done_testing;
|
||||
done_testing;
|
|
@ -12,7 +12,7 @@ zci is_cached => 0;
|
|||
|
||||
sub build_structured_answer{
|
||||
my($startDate, $endDate, $daysBetween, $inclusive) = @_;
|
||||
return "There are $daysBetween days between $startDate and $endDate$inclusive.",
|
||||
return "There are $daysBetween days between $startDate and $endDate$inclusive",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $daysBetween,
|
||||
|
|
|
@ -14,7 +14,7 @@ zci is_cached => 1;
|
|||
sub build_structured_answer {
|
||||
my ($numbers, $result) = @_;
|
||||
|
||||
return "Greatest common factor of $numbers is $result.",
|
||||
return "Greatest common factor of $numbers is $result",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $result,
|
||||
|
|
|
@ -13,7 +13,7 @@ sub build_test
|
|||
{
|
||||
my ($who, $article, $number) = @_;
|
||||
|
||||
return test_zci("$who $article the $number President of the United States.", structured_answer => {
|
||||
return test_zci("$who $article the $number President of the United States", structured_answer => {
|
||||
data => {
|
||||
title => $who,
|
||||
subtitle => "$number President of the United States"
|
||||
|
|
|
@ -12,7 +12,7 @@ zci answer_type => 'ohms';
|
|||
|
||||
sub build_structured_answer {
|
||||
my ($exp_input, $exp_result) = @_;
|
||||
return "A $exp_input resistor has a resistance of $exp_result.", structured_answer => {
|
||||
return "A $exp_input resistor has a resistance of $exp_result", structured_answer => {
|
||||
data => {
|
||||
title => "$exp_result",
|
||||
subtitle => "Resistance of $exp_input resistor"
|
||||
|
|
12
t/SunInfo.t
12
t/SunInfo.t
|
@ -13,7 +13,7 @@ zci is_cached => 0;
|
|||
|
||||
set_fixed_time('2014-08-01T00:00:00Z');
|
||||
# Presume sun will rise in the morning and set at night year round in PA.
|
||||
my @now = (re(qr/^On.*Phoenixville, Pennsylvania.*AM.*PM\.$/),
|
||||
my @now = (re(qr/^On.*Phoenixville, Pennsylvania.*AM.*PM$/),
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
|
@ -26,7 +26,7 @@ my @now = (re(qr/^On.*Phoenixville, Pennsylvania.*AM.*PM\.$/),
|
|||
}
|
||||
}
|
||||
);
|
||||
my @aug = (re(qr/^On 30 Aug.*AM.*PM\.$/),
|
||||
my @aug = (re(qr/^On 30 Aug.*AM.*PM$/),
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
|
@ -40,7 +40,7 @@ my @aug = (re(qr/^On 30 Aug.*AM.*PM\.$/),
|
|||
}
|
||||
);
|
||||
my @exact = (
|
||||
'On 01 Jan 2015, sunrise in Phoenixville, Pennsylvania is at 7:23 AM; sunset at 4:46 PM.',
|
||||
'On 01 Jan 2015, sunrise in Phoenixville, Pennsylvania is at 7:23 AM; sunset at 4:46 PM',
|
||||
structured_answer => {
|
||||
data => {
|
||||
rise => "7:23 AM",
|
||||
|
@ -87,7 +87,7 @@ ddg_goodie_test(
|
|||
}
|
||||
}
|
||||
),
|
||||
'sunset at 1S 1W' => test_zci(re(qr"On .*, sunrise in Coordinates -1°N -1°E is at .*AM; sunset at .*PM."),
|
||||
'sunset at 1S 1W' => test_zci(re(qr"On .*, sunrise in Coordinates -1°N -1°E is at .*AM; sunset at .*PM"),
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
|
@ -100,7 +100,7 @@ ddg_goodie_test(
|
|||
}
|
||||
}
|
||||
),
|
||||
'sunset at 53N 2E on 2014-01-01' => test_zci("On 01 Jan 2014, sunrise in Coordinates 53°N 2°E is at 3:05 AM; sunset at 10:46 AM.",
|
||||
'sunset at 53N 2E on 2014-01-01' => test_zci("On 01 Jan 2014, sunrise in Coordinates 53°N 2°E is at 3:05 AM; sunset at 10:46 AM",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
|
@ -113,7 +113,7 @@ ddg_goodie_test(
|
|||
}
|
||||
}
|
||||
),
|
||||
'sunset at 53N 2W on 2014-01-08' => test_zci("On 08 Jan 2014, sunrise in Coordinates 53°N -2°E is at 3:18 AM; sunset at 11:11 AM.",
|
||||
'sunset at 53N 2W on 2014-01-08' => test_zci("On 08 Jan 2014, sunrise in Coordinates 53°N -2°E is at 3:18 AM; sunset at 11:11 AM",
|
||||
structured_answer => {
|
||||
data => ignore(),
|
||||
templates => {
|
||||
|
|
|
@ -9,12 +9,12 @@ use DDG::Test::Goodie;
|
|||
zci answer_type => "twelve_oclock";
|
||||
zci is_cached => 1;
|
||||
|
||||
my $noon = '12:00pm is noon.';
|
||||
my $midnight = '12:00am is midnight.';
|
||||
my $correct_midnight = 'Yes, 12:00am is midnight.';
|
||||
my $correct_noon = 'Yes, 12:00pm is noon.';
|
||||
my $wrong_midnight = 'No, 12:00am is midnight.';
|
||||
my $wrong_noon = 'No, 12:00pm is noon.';
|
||||
my $noon = '12:00pm is noon';
|
||||
my $midnight = '12:00am is midnight';
|
||||
my $correct_midnight = 'Yes, 12:00am is midnight';
|
||||
my $correct_noon = 'Yes, 12:00pm is noon';
|
||||
my $wrong_midnight = 'No, 12:00am is midnight';
|
||||
my $wrong_noon = 'No, 12:00pm is noon';
|
||||
|
||||
sub build_test {
|
||||
my ($text) = @_;
|
||||
|
|
16
t/Week.t
16
t/Week.t
|
@ -10,7 +10,7 @@ use Test::MockTime qw( :all );
|
|||
zci answer_type => "week";
|
||||
zci is_cached => 1;
|
||||
|
||||
my $current_week_re = re(qr/We are currently in the \d{1,2}\w{2} week of \d{4}./);
|
||||
my $current_week_re = re(qr/We are currently in the \d{1,2}\w{2} week of \d{4}/);
|
||||
|
||||
sub build_test {
|
||||
my ($answer) = @_;
|
||||
|
@ -35,11 +35,11 @@ ddg_goodie_test(
|
|||
"what's the current week? " => build_test($current_week_re),
|
||||
"whats the current week of the year" => build_test($current_week_re),
|
||||
|
||||
"what was the 43rd week of 1984" => build_test("The 43rd week of 1984 began on October 22nd."),
|
||||
"what was the 8th week of 1956" => build_test("The 8th week of 1956 began on February 20th."),
|
||||
"what was the 21st week of 1987" => build_test("The 21st week of 1987 began on May 18th."),
|
||||
"what was the 43rd week of 1984" => build_test("The 43rd week of 1984 began on October 22nd"),
|
||||
"what was the 8th week of 1956" => build_test("The 8th week of 1956 began on February 20th"),
|
||||
"what was the 21st week of 1987" => build_test("The 21st week of 1987 began on May 18th"),
|
||||
|
||||
'what was the 5th week of 1944' => build_test("The 5th week of 1944 began on January 31st."),
|
||||
'what was the 5th week of 1944' => build_test("The 5th week of 1944 began on January 31st"),
|
||||
'what was the 5th week of 0000' => undef,
|
||||
"what was the 0 week of 2011" => undef,
|
||||
"what was the 99th week of 2011" => undef,
|
||||
|
@ -48,16 +48,16 @@ ddg_goodie_test(
|
|||
set_fixed_time('2014-01-01T00:00:00');
|
||||
ddg_goodie_test(
|
||||
['DDG::Goodie::Week'],
|
||||
'when is the 8th week of 2015' => build_test("The 8th week of 2015 begins on February 16th.")
|
||||
'when is the 8th week of 2015' => build_test("The 8th week of 2015 begins on February 16th")
|
||||
);
|
||||
restore_time();
|
||||
|
||||
set_fixed_time('2015-07-31T00:00:00');
|
||||
ddg_goodie_test(
|
||||
['DDG::Goodie::Week'],
|
||||
'when is the 8th week of 2015' => build_test("The 8th week of 2015 began on February 16th."),
|
||||
'when is the 8th week of 2015' => build_test("The 8th week of 2015 began on February 16th"),
|
||||
# Nth Week Queries
|
||||
"what was the 5th week of this year" => build_test(re(qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}\./))
|
||||
"what was the 5th week of this year" => build_test(re(qr/The \d{1,2}\w{2} week of \d{4} (begins|began) on January \d{1,2}\w{2}/))
|
||||
);
|
||||
restore_time();
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ my @jan_6_to_10 = ('06 Jan 2014', '10 Jan 2014', 5, @plural);
|
|||
sub build_structured_answer {
|
||||
my( $start_str, $end_str, $weekday_count, $verb, $weekday_plurality) = @_;
|
||||
|
||||
my $response = "There $verb $weekday_count $weekday_plurality between $start_str and $end_str.";
|
||||
my $response = "There $verb $weekday_count $weekday_plurality between $start_str and $end_str";
|
||||
return $response,
|
||||
structured_answer => {
|
||||
data => {
|
||||
|
|
|
@ -17,11 +17,11 @@ sub build_structured_answer {
|
|||
$converted_mass = "($mass_kg kg) ";
|
||||
}
|
||||
|
||||
return "Weight of a $mass mass on Earth is ${weight}N.",
|
||||
return "Weight of a $mass mass on Earth is ${weight}N",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => "Weight of a $mass ${converted_mass}mass on Earth is ${weight}N.",
|
||||
subtitle => "Taking value of acceleration due to gravity on Earth as 9.80665m/s^2."
|
||||
title => "Weight of a $mass ${converted_mass}mass on Earth is ${weight}N",
|
||||
subtitle => "Taking value of acceleration due to gravity on Earth as 9.80665m/s^2"
|
||||
},
|
||||
templates => {
|
||||
group => "text"
|
||||
|
|
|
@ -25,12 +25,12 @@ my @jan_3_to_6_weekend_middle = ('03 Jan 2014', '06 Jan 2014', 2, @plural);
|
|||
sub build_structured_answer {
|
||||
my ($start_str, $end_str, $workdays, $verb, $number, $regex) = @_;
|
||||
|
||||
my $response = re(qr/There $verb $workdays $number between $start_str and $end_str./);
|
||||
my $response = re(qr/There $verb $workdays $number between $start_str and $end_str/);
|
||||
my $subtitle = re(qr/Workdays between $start_str - $end_str/);
|
||||
my $title = re($workdays);
|
||||
|
||||
if(!$regex) {
|
||||
$response = "There $verb $workdays $number between $start_str and $end_str.";
|
||||
$response = "There $verb $workdays $number between $start_str and $end_str";
|
||||
$title = $workdays;
|
||||
$subtitle = "Workdays between $start_str - $end_str";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue