I am using WordNetLemmatizer() function in NLTK package in python to lemmatize the entire sentence of movie review dataset.
Here is my code:
from nltk.stem import LancasterStemmer, WordNetLemmatizer
lemmer = WordNetLemmatizer()
def preprocess(x):
#Lemmatization
x = ' '.join([lemmer.lemmatize(w) for w in x.rstrip().split()])
# Lower case
x = x.lower()
# Remove punctuation
x = re.sub(r'[^\w\s]', '', x)
# Remove stop words
x = ' '.join([w for w in x.split() if w not in stop_words])
## EDIT CODE HERE ##
return x
df['review_clean'] = df['review'].apply(preprocess)
review in df is the column of text reviews that I wanted to process
After using the preprocess function on df, the new column review_clean contains cleaned text data but it still does not have lemmatized text. eg. I can see a lot words ends with -ed, -ing.
Thanks in advance.