Hapus Stopwords dari daftar string python
from nltk.corpus import stopwords
stopwords=set(stopwords.words('english'))
data =['I really love writing journals','The mat is very comfortable and I will buy it again likes','The mousepad is smooth']
def remove_stopwords(data):
output_array=[]
for sentence in data:
temp_list=[]
for word in sentence.split():
if word.lower() not in stopwords:
temp_list.append(word)
output_array.append(' '.join(temp_list))
return output_array
output=remove_stopwords(data)
print(output)
['really love writing journals','mat comfortable buy likes', 'mousepad smooth']
NotACoder