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

Date comparison bug #48

Open
cegme opened this issue Jan 29, 2018 · 1 comment
Open

Date comparison bug #48

cegme opened this issue Jan 29, 2018 · 1 comment

Comments

@cegme
Copy link

cegme commented Jan 29, 2018

In the check_date function, there are lines of code here, here,here, and here that compare integers with string using a value comparison. The date attribute of the NounPhrase class and its Phrase superclass are strings. These lines don't throw errors in Python2 but they do in Python3.

Also, I'm not sure it works as intended. When going through the test_noun_meaning1 test, we see the following conflict.

>>> '081315' >= int('150578')
True
>>> int('081315') >= int('150578')
False

Here is the output of Python3

>>> '081315' >= int('150578')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: '>=' not supported between instances of 'str' and 'int'
>>> int('081315') >= int('150578')
False

What should the expected behavior be here?

It looks like we should be comparing the dstr_to_ordate(curdate) to the integer date. Here the dstr_to_ordate.

@cegme
Copy link
Author

cegme commented Jan 29, 2018

Apparently, integer types are always less than non-integer types. https://stackoverflow.com/a/3270689/235820

Swapping one of the comparisons helps a test case pass str(int(curdate)) >= str(int(date[0][1:])) 🤷

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