def mk_label(line,d,thre):
import math
from nltk import stem
stemmer=stem.PorterStemmer()
score=0
for item in line.strip("\n").split(" "):
item=stemmer.stem(item)
score+=d[item]
p_pos=math.exp(score)/(1+math.exp(score))
if p_pos > thre:
return(line.split(" ")[0]+"\t+1\t"+str(p_pos))
else:
return(line.split(" ")[0]+"\t-1\t"+str(p_pos))
评论列表
文章目录