“Hapus Stopwords” Kode Jawaban

Hapus Stopwords

from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
 
example_sent = """This is a sample sentence,
                  showing off the stop words filtration."""
 
stop_words = set(stopwords.words('english'))
 
word_tokens = word_tokenize(example_sent)
 
filtered_sentence = [w for w in word_tokens if not w.lower() in stop_words]
Hurt Hedgehog

Hapus Stopwords

traindf['title'] = traindf['title'].apply(lambda x: ' '.join([word for word in x.lower().split() if word not in 
                                                            stopwords.words('english') and string.punctuation]))
Clear Copperhead

Jawaban yang mirip dengan “Hapus Stopwords”

Pertanyaan yang mirip dengan “Hapus Stopwords”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya