Closed countlurk closed 8 years ago
Its because the potus is triggered if the query contain the substrings "president of the united states" or "president of the us"
@hemanth should be as simple as adding a ^
to the front
@mintsoft Yes, I am aware of that, giving a chance to the person who reported to do a PR ;)
Looks like this still needs fixing @hemanth, care to fix it?
@moollaza Sure, what the expected triggers here? In the RE
just a beings with for who\s+(is|was)\s+the\s+
is enough?
The triggers are OK, but we shouldn't just be stripping out expected query parts. We need to ensure that the whole query matches our regex:
handle query_lc => sub {
return unless m/^(?:who (?:is|was) the )?(\d+(?:st|nd|rd|th))?(?:potus|president of the (?:us|united states|usa)) (\d+)?$/;
...
Something like that...
We should add tests to ensure this.
I would also just use triggers any => "potus", "president ... ";
return unless my ($tense, $index, $text) = $_ =~ ^(?:who (?:is|was) the )?(\d+(?:st|nd|rd|th))?(?:potus|president of the (?:us|united states|usa)) ?(\d+)?$
Something like ^ and then fetch the required index from @presidents
?
@hemanth sure -- not sure you need to capture anything besides the index though.
We can derive is/was
if index is/isn't the current president.
"Sorry, no hit for your instant answer"
Well with the modified R.E I see ^ missing something?
Update, I think it would make more sense to do a PR and take it from there. #1913
Where do I see the debug logs? The duckpan server doesn't respect print?
@moollaza
@hemanth use warn
-- you'll see it printed in DuckPAN's server output
Used use warn;
but it's not triggering instant answer for any of the valid phrases: POTUS
et.al
@numbertheory Searching for "vice president of the united states" triggers this instant answer, giving the incorrect output of Barack Obama
IA Page: http://duck.co/ia/view/potus