MulaiMulai sekarang secara gratis

Lemmatization

While continuing your analysis of user reviews, you noticed that stemming sometimes produces non-standard words like "fli" from "flying", which can reduce interpretability. To address this, you'll now use lemmatization, which returns actual words and helps improve the clarity and accuracy of your analysis.

WordNetLemmatizer has been imported, stop_words has been defined, and the necessary NLTK resources have been downloaded.

Latihan ini adalah bagian dari kursus

Natural Language Processing (NLP) in Python

Lihat Kursus

Petunjuk latihan

  • Create an instance lemmatizer of the WordNetLemmatizer() class.
  • Use the lemmatizer to lemmatize the lower_tokens.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

clean_tokens = ['flying', 'lot', 'lately', 'flights', 'keep', 'getting', 'delayed', 'honestly', 'traveling', 'work', 'gets', 'exhausting', 'endless', 'delays', 'every', 'travel', 'teaches', 'something', 'new']

# Create lemmatizer
lemmatizer = ____()

# Lemmatize each token
lemmatized_tokens = [____.____(____) for ____ in clean_tokens]

print(lemmatized_tokens)
Edit dan Jalankan Kode