dipanjanS / practical-machine-learning-with-python

Master the essential skills needed to recognize and solve complex real-world problems with Machine Learning and Deep Learning by leveraging the highly popular Python Machine Learning Eco-system.
Apache License 2.0
2.28k stars 1.65k forks source link

word.lemma_ will lowercase the token #14

Open HuaizhengZhang opened 5 years ago

HuaizhengZhang commented 5 years ago

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 commented 5 years ago

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

dipanjanS commented 5 years ago

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.

HuaizhengZhang commented 5 years ago

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

HuaizhengZhang commented 5 years ago

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

dipanjanS commented 5 years ago

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