Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace issue in parser #95

Open
dcastro opened this issue Aug 29, 2023 · 2 comments
Open

Whitespace issue in parser #95

dcastro opened this issue Aug 29, 2023 · 2 comments
Milestone

Comments

@dcastro
Copy link
Member

dcastro commented Aug 29, 2023

Clarification and motivation

At the moment, the parser only recognizes time references if:

  • they're immediately at the beginning of the message: "9am"
  • or after a space: "I can't go today, let's try 9am tomorrow instead"

This is implemented here:

tzbot/src/TzBot/Parser.hs

Lines 274 to 275 in 0f58a50

-- time reference can be either at the beginning or after a space
. (Whitespace :)

_ <- space

tzbot/src/TzBot/Parser.hs

Lines 339 to 340 in 0f58a50

-- no space here before `timeRefGroupParser` requires a space before the contents
secondGroup <- timeRefGroupParser

The rationale is to avoid parsing things like "The product ID is AEH9AM" as "9AM".

However, there can be situations where a legitimate time reference is not actually preceded by a space:

>>> parseTimeRefs "How about Mike's suggestion (9am tomorrow)?"
[]

We should be able to parse these.

@dcastro
Copy link
Member Author

dcastro commented Sep 5, 2023

Here's a real-world example:
image

Notice how (5 pm MSK, 4 pm CET) was incorrectly interpreted as MSK, 4 pm. The 5 pm part was ignored because it was not preceded by a whitespace.

@dcastro dcastro added this to the v1 milestone Sep 7, 2023
@dcastro
Copy link
Member Author

dcastro commented Oct 3, 2023

Yes another real-world example:

it will be at 11 AM CEST (9 AM UTC+0, 12 PM MSK)

The bot parsed UTC+0, 12 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant