practical-machine-learning-with-python icon indicating copy to clipboard operation
practical-machine-learning-with-python copied to clipboard

word.lemma_ will lowercase the token

Open HuaizhengZhang opened this issue 6 years ago • 5 comments

text = ' '.join([word.lemma_ if word.lemma_ != '-PRON-' else word.text for word in text])

In the latest Spacy, after I run the code, the text will be lowercased. Actually, I do not want to do this at this stage. I think this is an issue.

HuaizhengZhang avatar Jan 22 '19 04:01 HuaizhengZhang

https://github.com/dipanjanS/practical-machine-learning-with-python/blob/master/bonus%20content/nlp%20proven%20approach/NLP%20Strategy%20I%20-%20Processing%20and%20Understanding%20Text.ipynb

HuaizhengZhang avatar Jan 22 '19 04:01 HuaizhengZhang

That would be more of a spacy issue I think, as far as I know typically any lemmatizer returns text in lower case. You might consider checking nltk but I am pretty sure they do the same.

Only option for you is to check the case of each word beforehand and then manually convert the case of the lemma after lemmatization if needed. Otherwise would need to send this request upstream to the spacy or nltk devs.

dipanjanS avatar Jan 22 '19 05:01 dipanjanS

Do we need to add some comments to explain this in your practical-machine-learning-with-python?

HuaizhengZhang avatar Jan 22 '19 06:01 HuaizhengZhang

People may be confused to see their results because no matter how they set the do_lowercase, they always get the lowercased text.

HuaizhengZhang avatar Jan 22 '19 06:01 HuaizhengZhang

yes definitely, that would be a good point to mention I think

dipanjanS avatar Jan 22 '19 21:01 dipanjanS