Natural Language Processing (NLP) in Python
Fouad Trad
Machine Learning Engineer
text = """Data scientists and data engineers need DATA""" lower_text = text.lower()
print(lower_text)
data scientists and data
engineers need data
Tasks relying on keyword analysis
Tasks relying on keyword analysis
Tasks requiring distinction between words that depend on case for meaning
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
tokens = ['running', 'bats', 'organizations', 'reading']
stemmed = [stemmer.stem(word) for word in tokens]
print(stemmed)
['run', 'bat', 'organizat', 'read']
from nltk.stem import WordNetLemmatizer
nltk.download('wordnet')
lemmatizer = WordNetLemmatizer()
tokens = ['running', 'bats', 'organizations', 'reading']
lemmatized = [lemmatizer.lemmatize(word) for word in tokens]
print(lemmatized)
['running', 'bat', 'organization', 'reading']
Natural Language Processing (NLP) in Python