Timer: Triggering fixes (#4446)

* Adds join-word of

* Stops triggering on time calculations

* Comment fixes
master
Nalin Bhardwaj 2017-08-23 00:45:25 +05:30 committed by Rob Emery
parent 4bf20c33b2
commit 894ef122c0
2 changed files with 14 additions and 3 deletions

View File

@ -8,7 +8,7 @@ zci answer_type => 'timer';
zci is_cached => 1;
my @triggers = ('timer', 'countdown', 'count down', 'alarm', 'reminder');
# Triggers that are vaild, but not stripped from the resulting query
# Triggers that are valid, but not stripped from the resulting query
my @nonStrippedTriggers = qw(minutes mins seconds secs hours hrs);
# Triggers that are valid in start only
my @baseTriggers = qw(start begin set run);
@ -20,7 +20,7 @@ push(@startTriggers, @baseTriggers);
# Beautifies the trigger can be appended in front/back of trigger
my @beautifierTriggers = qw(online);
#Joins the Timer Value
my @joiners = qw(for on at to with);
my @joiners = qw(for on at to with of);
# StartEndTriggers to trigger on nonStrippedTriggers, startTriggers, beautifierTriggers and triggers
my @triggersStartEnd = (@triggers, @nonStrippedTriggers, @startTriggers, @beautifierTriggers);
# Ambigous triggers which should not give Timer IA
@ -117,6 +117,13 @@ handle remainder => sub {
if($raw =~ /^($ambTrgx)$/){
return;
}
# When query doesn't ask for timer explicitly and just wants time
# calculations, don't invoke IA.
if($raw !~ /($trgx)/ and $raw =~ /[+-]/) {
return;
}
# When the query is empty and we know that the trigger word matches
# the trigger exactly (whitespace check) we can return a valid result
if($qry eq '') {

View File

@ -104,6 +104,8 @@ ddg_goodie_test(
'timer 60 minutes' => build_test('3600'),
'start a timer for 20 minutes' => build_test('1200'),
'set a timer to 60 minutes' => build_test('3600'),
'set a timer of 60 minutes' => build_test('3600'),
'timer of 5:15 mins' => build_test('315'),
# Should not trigger
'start 30 minutes for timer' => undef,
'run with timer' => undef,
@ -121,7 +123,9 @@ ddg_goodie_test(
'20 minutes' => undef,
' 22 minutes' => undef,
'60 minutes' => undef,
'48 hours ' => undef
'48 hours ' => undef,
'5:15 + 32 minutes' => undef,
'3:32 - 8 mins' => undef
);
done_testing;