like_num returns false if a numeric word is not lowercased
I am using rule-based matching and noticed that some patterns containing "LIKE_NUM": True are not matching phrases, where numeric words are not in lowercase (in my case some sentences start with numeric words that are capitalized).
It could be easily checked:
import spacy
nlp = spacy.load('en')
def like_num(text):
doc = nlp(text)
print(doc[0].like_num)
like_num("twenty") # True
like_num("20") # True
like_num("Twenty") # False
like_num("TWENTY") # False
like_num("tWenTY") # False
Maybe like_num attribute should check lowercased form of a token?
Environment
- Operating System: macOS High Sierra
- Python Version Used: 3.6.3
- spaCy Version Used: 2.0.3
Thanks, good point! The implementation is here:
https://github.com/explosion/spaCy/blob/03a2f540caedf2c92d6a2151a72108ca2a297a50/spacy/lang/en/lex_attrs.py#L15-L25
It looks like just changing it to if text.lower() in _num_words should work, right? If you want to test this and submit a PR, this would be great 👍
@ines sure! Will do within a week or two.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.