【发布时间】:2019-08-24 22:41:46
【问题描述】:
我是 python 编程的新手。我有两个列表,第一个列表包含停用词,另一个包含文本文档。我想用“/”替换文本文档中的停用词。有没有人可以帮忙?
我用了replace函数,报错了
text = "This is an example showing off word filtration"
stop = `set`(stopwords.words("english"))
text = nltk.word_tokenize(document)
`for` word in stop:
text = text.replace(stop, "/")
`print`(text)
它应该输出 "///示例显示/单词过滤"
【问题讨论】:
标签: python-3.x