我正在打开每个文本文件并为其分配一个标签-用来训练NaiveBayes分类器的pos或neg。该数据集包含约12,000个txt文件。我正在使用TextBlob库进行情感分析
train = [('I dont like this movie','neg')]
path = 'C://TextDemo//senti//aclImdb//train//neg//*.txt'
for f in glob.glob(path):
with open(f, "r", encoding="UTF-8") as read_file:
for line in read_file:
train.append(((line.replace("<br />","")),'pos'))
cl = NaiveBayesClassifier(train)