为什么 kenlm 模型返回相同的值?我也尝试过使用 4-gram arpa 文件。同样的问题。
import kenlm
model = kenlm.mode('lm/test.arpa') # unigram model.
print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a sentence', bos=False, eos=False)])
print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a sentence1', bos=False, eos=False)])
print( [f'{x[0]:.2f}, {x[1]}, {x[2]}' for x in model.full_scores('this is a devil', bos=False, eos=False)])
结果:
['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']
['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']
['-2.00, 1, True', '-21.69, 1, False', '-1.59, 1, False', '-2.69, 1, True']