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

fix "ass" being interpreted as a time #173

Merged
merged 1 commit into from
Aug 11, 2016
Merged

fix "ass" being interpreted as a time #173

merged 1 commit into from
Aug 11, 2016

Conversation

jonklein
Copy link
Collaborator

@jonklein jonklein commented Aug 11, 2016

Well, honestly this issue is immediately top of the list for "Most Amusing Bug of 2016". We were puzzled as to why our app was behaving incorrectly whenever the word "ass" was used in a sentence. We soon found that parsedatetime is treating "ass" as a time:

>>> import parsedatetime
>>> parsedatetime.Calendar().nlp("nice ass")
((datetime.datetime(2016, 8, 10, 20, 5, 35), 2, 5, 8, 'ass'),)

We tracked the issue down to a curious QUNITS regular expression which matches the word "a" as the number 1, the letter "s", and then another "s" for "seconds" (it would also match the word "ash" via the same logic with "hours"). We couldn't quite make sense of the second "s" in the regular expression and believe it should have been "\s" instead - making that change fixes the issue.

This PR also fixes a time-sensitive spec that started failing a couple of days ago.

cc @bgalbraith


This change is Reviewable

@codecov-io
Copy link

codecov-io commented Aug 11, 2016

Current coverage is 76.89% (diff: 100%)

Merging #173 into master will not change coverage

@@             master       #173   diff @@
==========================================
  Files            14         14          
  Lines          1567       1567          
  Methods           0          0          
  Messages          0          0          
  Branches        288        288          
==========================================
  Hits           1205       1205          
  Misses          268        268          
  Partials         94         94          

Powered by Codecov. Last update 91d122d...e45c646

@bear
Copy link
Owner

bear commented Aug 11, 2016

Reviewed 3 of 3 files at r1.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@bear
Copy link
Owner

bear commented Aug 11, 2016

What a hilarious bug!

It took me a couple of minutes scanning the QUNITS regex to even spot the change - wow s \s

thanks for the fixes!

@bear bear merged commit 63e65e2 into bear:master Aug 11, 2016
@jonklein jonklein deleted the fix/ass branch August 11, 2016 12:50
@idpaterson idpaterson modified the milestone: 2.2 Aug 24, 2016
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

Successfully merging this pull request may close these issues.

4 participants