knock76.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:100knock2016 作者: tmu-nlp 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号