hmm.py 文件源码

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

项目:rensapy 作者: RensaProject 项目源码 文件源码
def test_pos(model, sentences, display=False):
    from sys import stdout

    count = correct = 0
    for sentence in sentences:
        sentence = [(token[0], None) for token in sentence]
        pts = model.best_path(sentence)
        if display:
            print sentence
            print 'HMM >>>'
            print pts
            print model.entropy(sentences)
            print '-' * 60
        else:
            print '\b.',
            stdout.flush()
        for token, tag in zip(sentence, pts):
            count += 1
            if tag == token[TAG]:
                correct += 1

    print 'accuracy over', count, 'tokens %.1f' % (100.0 * correct / count)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号