【发布时间】:2013-12-17 09:32:34
【问题描述】:
我正在尝试使用.join 函数从用户输入字符串中删除停用词。它看起来像这样:
while True:
line = raw_input()
if line.strip() == stopword:
break
remove_stopwords = ''.join(word for word in line.split() if word not in stop_words)
我在顶部的列表中定义了stop_words。问题是,当我输入要删除的停用词的字符串时,它只会删除第一个单词并留下其余单词。任何帮助都会很棒。我是新手,所以这可能很愚蠢。
【问题讨论】:
-
stopword声明在哪里? -
哦,这也是在显示的代码上方声明的。当输入仅包含句号的行时,它被设置为中断。
标签: python python-2.7 stop-words