【发布时间】:2017-06-21 21:10:39
【问题描述】:
我有一个处理过的文本文件列表,看起来有点像这样:
text = "这是第一个文本文档"这是第二个文本文档"这是第三个文档"
我已经能够成功地标记句子:
sentences = sent_tokenize(text)
for ii, sentence in enumerate(sentences):
sentences[ii] = remove_punctuation(sentence)
sentence_tokens = [word_tokenize(sentence) for sentence in sentences]
现在我想从这个标记列表中删除停用词。
但是,因为它是文本文档列表中的句子列表,我似乎无法弄清楚如何做到这一点。
这是我迄今为止尝试过的,但它没有返回任何结果:
sentence_tokens_no_stopwords = [w for w in sentence_tokens if w not in stopwords]
我假设实现这一点需要某种 for 循环,但我现在所拥有的不起作用。任何帮助将不胜感激!
【问题讨论】: