我有几个要使用的文本文件(本地文件夹),并且要从此文件夹中的每个文件中删除停用词,然后将新文件保存在一个子文件夹中。一个文件的代码:import iofrom nltk.corpus import stopwordsfrom nltk.tokenize import word_tokenizestop_words = set(stopwords.words('english'))file1 = open("1_1.txt")line = file1.read()words = line.split()for r in words: if not r in stop_words: appendFile = open('subfolder/1_1.txt','a') appendFile.write(" "+r) appendFile.close()我想我必须尝试使用glob吗?但是我似乎并不了解文档。我也许应该降低文本的文本?一定有一种超级简单的方法,但是我只为一个句子或一个文件找到教程,从不为多个文件找到教程。
添加回答
举报
0/150
提交
取消