def make_feature(f, flag):
with open(file_name) as f:
feature = defaultdict(int)
for i,line in enumerate(f):
print(i)
y,x = line.split('\t')
y = int(y)
words = x.split()
for word in words:
if stop_word_check(word) == False:
word = stem.PorterStemmer().stem(word)
if flag == 0:
feature[word] += 1
elif flag == 1:
if y == 1:
feature[word] += 1
elif y == -1:
feature[word] -= 1
return feature
评论列表
文章目录