Я хочу сделать список всех текстовых файлов в каталоге.тогда я хочу создать отдельный список содержимого в каждом файле.например, document1 = [], а затем document2 = [] и так далее.а затем, используя ключевые слова «документ 1» и «документ 2», я хочу вычислить частоту термина и другие процессы.код выполняется, но списку нельзя присвоить разные имена, как document1 и т. д.
import glob
import math
import re
a=0
flist=glob.glob(r'D:/Final Year Project/Development process/Text_data_extraction/MyFolder/*.txt') #get all the files from the d`#open each file >> tokenize the content >> and store it in a set
for fname in flist:
tfile=open(fname,"r")
line=tfile.read()
a+=1
line = line.lower() # lowercase
line = re.sub("</?.*?>"," <> ",line) #remove tags
line = re.sub("(\\d|\\W)+"," ",line) # remove special characters and digits
l_ist = line.split("\n")
print 'document'
print(l_ist)
tfile.close() # close the file
print"Number of documents:"
print(a)