Timer: Triggering fixes (#4446)
* Adds join-word of * Stops triggering on time calculations * Comment fixesmaster
parent
4bf20c33b2
commit
894ef122c0
|
@ -8,7 +8,7 @@ zci answer_type => 'timer';
|
||||||
zci is_cached => 1;
|
zci is_cached => 1;
|
||||||
|
|
||||||
my @triggers = ('timer', 'countdown', 'count down', 'alarm', 'reminder');
|
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);
|
my @nonStrippedTriggers = qw(minutes mins seconds secs hours hrs);
|
||||||
# Triggers that are valid in start only
|
# Triggers that are valid in start only
|
||||||
my @baseTriggers = qw(start begin set run);
|
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
|
# Beautifies the trigger can be appended in front/back of trigger
|
||||||
my @beautifierTriggers = qw(online);
|
my @beautifierTriggers = qw(online);
|
||||||
#Joins the Timer Value
|
#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
|
# StartEndTriggers to trigger on nonStrippedTriggers, startTriggers, beautifierTriggers and triggers
|
||||||
my @triggersStartEnd = (@triggers, @nonStrippedTriggers, @startTriggers, @beautifierTriggers);
|
my @triggersStartEnd = (@triggers, @nonStrippedTriggers, @startTriggers, @beautifierTriggers);
|
||||||
# Ambigous triggers which should not give Timer IA
|
# Ambigous triggers which should not give Timer IA
|
||||||
|
@ -117,6 +117,13 @@ handle remainder => sub {
|
||||||
if($raw =~ /^($ambTrgx)$/){
|
if($raw =~ /^($ambTrgx)$/){
|
||||||
return;
|
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
|
# When the query is empty and we know that the trigger word matches
|
||||||
# the trigger exactly (whitespace check) we can return a valid result
|
# the trigger exactly (whitespace check) we can return a valid result
|
||||||
if($qry eq '') {
|
if($qry eq '') {
|
||||||
|
|
|
@ -104,6 +104,8 @@ ddg_goodie_test(
|
||||||
'timer 60 minutes' => build_test('3600'),
|
'timer 60 minutes' => build_test('3600'),
|
||||||
'start a timer for 20 minutes' => build_test('1200'),
|
'start a timer for 20 minutes' => build_test('1200'),
|
||||||
'set a timer to 60 minutes' => build_test('3600'),
|
'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
|
# Should not trigger
|
||||||
'start 30 minutes for timer' => undef,
|
'start 30 minutes for timer' => undef,
|
||||||
'run with timer' => undef,
|
'run with timer' => undef,
|
||||||
|
@ -121,7 +123,9 @@ ddg_goodie_test(
|
||||||
'20 minutes' => undef,
|
'20 minutes' => undef,
|
||||||
' 22 minutes' => undef,
|
' 22 minutes' => undef,
|
||||||
'60 minutes' => undef,
|
'60 minutes' => undef,
|
||||||
'48 hours ' => undef
|
'48 hours ' => undef,
|
||||||
|
'5:15 + 32 minutes' => undef,
|
||||||
|
'3:32 - 8 mins' => undef
|
||||||
);
|
);
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue