SRILM使用之训练无平滑语言模型

【语料准备】
训练语料

wget http://idiom.ucsd.edu/~rlevy/teaching/2015winter/lign165/lectures/lecture13/toy-example/corpus.txt

测试语料

wget http://idiom.ucsd.edu/~rlevy/teaching/2015winter/lign165/lectures/lecture13/toy-example/test_corpus.txt

训练语料内容

$ cat corpus.txt

dogs chase cats
dogs bark
cats meow
dogs chase birds
cats chase birds
dogs chase the cats
the birds chirp

【计数文件生成】 此步在实际应用中不需要

ngram-count -text corpus.txt -order 2 -write1 corpus_1gram.count -write2 corpus_2gram.count

将计数文件分别输出到1-gram文件和2-gram文件

【模型文件生成】

ngram-count -text corpus.txt -debug 2 -order 2 -addsmooth 0 -lm corpus.lm

这里使用-addsmooth 0 参数,使模型不进行平滑处理
对模型文件的分析 此处省略了一些数据,详见excel
第1部分
这里写图片描述

第2部分
这里写图片描述

这里写图片描述
第3部分
这里写图片描述

这里写图片描述

【计算测试文件困惑度】

ngram -lm corpus.lm -ppl test_corpus.txt -debug 2

这里写图片描述

其中:每一行代表可以从lm文件中查到的条件概率,第1列概率表示,第2列说明是几元条件概率,第3列概率值,第4列为概率值取对数。
logprob为整个句子的概率,它是由所有行概率值相加得到的。
ppl为困惑度,它是由公式10^-logprob/(#sen+#words)计算得到的。
以第1句话为例:ppl=10^-(-1.44716)/(1+4)=1.94729。
ppl1为困惑度,它是由公式 10^-logprob/#words计算得到的。
以第1句话为例:ppl1=10^-(-1.44716)/4=2.30033。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值