Natural Language Processing
So this one will be about stemming. Stemming is used in NLP for various reasons Stemming is removing certain parts of the word to get the meaning of it. For example, Running when stemmed returns run, and cooking when stemmed returns cook.
from nltk.stem import PorterStemmer from nltk.tokenize import word_tokenize # testing with a sentence sent = "when we run we get healthy, Running is awesome. I have ran for may miles." myWords = word_tokenize(sent) for w in myWords: print(PorterStemmer().stem(w)) print("**********Custom List************") # Testing with several custom words listwords = ["come", "came", "coming", "run", "running", "added", "adding"] for w in listwords: print(PorterStemmer().stem(w))
The output will be as follows: