📜  从字符串列表中删除停用词 python 代码示例

📅  最后修改于: 2022-03-11 14:46:04.302000             🧑  作者: Mango

代码示例1
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']