Challenge: Stemming
Oppgave
Swipe to start coding
You are given some text in text
variable. Your task is to tokenize this text, remove the stop words, and apply stemming on tokens. To do this:
- Import Porter Stemmer.
- Convert
text
to lowercase and save it intext_lower
. - Tokenize the
text_lower
string and save the result intokens
. - Load English stop words, convert them to
set
, and save instop_words
. - Filter out the stop words using list comprehension and save the result in
filtered_tokens
. - Create a Porter Stemmer and save it in
stemmer
. - Stem the tokens using list comprehension and save the result in
stemmed_tokens
.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 2
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Suggested prompts:
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 3.45
Challenge: Stemming
Sveip for å vise menyen
Oppgave
Swipe to start coding
You are given some text in text
variable. Your task is to tokenize this text, remove the stop words, and apply stemming on tokens. To do this:
- Import Porter Stemmer.
- Convert
text
to lowercase and save it intext_lower
. - Tokenize the
text_lower
string and save the result intokens
. - Load English stop words, convert them to
set
, and save instop_words
. - Filter out the stop words using list comprehension and save the result in
filtered_tokens
. - Create a Porter Stemmer and save it in
stemmer
. - Stem the tokens using list comprehension and save the result in
stemmed_tokens
.
Løsning
Alt var klart?
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 3.45Seksjon 2. Kapittel 2
single