MulaiMulai sekarang secara gratis

Stemming

Now that you've cleaned the review text and removed stop words and punctuation, you're ready to normalize the remaining words using stemming to reduce words to their root form. This helps group similar words together, making your analysis more consistent and efficient.

The PorterStemmer class has been provided, along with a list of clean_tokens.

Latihan ini adalah bagian dari kursus

Natural Language Processing (NLP) in Python

Lihat Kursus

Petunjuk latihan

  • Initialize the PorterStemmer().
  • Use a list comprehension to stem each token from the clean_tokens list.

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 stemmer
stemmer = ____()

# Stem each token
stemmed_tokens = [____.____(____) for ____ in clean_tokens]

print(stemmed_tokens)
Edit dan Jalankan Kode