BLEU 계산 (수정)
Name: nltk
Version: 3.2.5
Summary: Natural Language Toolkit
Home-page: http://nltk.org/
Author: Steven Bird
Author-email: stevenbird1@gmail.com
License: Apache License, Version 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: six
Required-by: textblob
from nltk.translate.bleu_score import SmoothingFunction, modified_precision, sentence_bleu
ref = ['the cat is on the mat'.split()]
sentence = 'the the the the the the the'.split()
p1 = modified_precision(ref, sentence, 1)
float(p1)
0.2857142857142857
p2 = modified_precision(ref, sentence, 2)
float(p2)
0.0
sentence_bleu(ref, sentence)
/usr/local/lib/python3.6/dist-packages/nltk/translate/bleu_score.py:516: UserWarning:
The hypothesis contains 0 counts of 2-gram overlaps.
Therefore the BLEU score evaluates to 0, independently of
how many N-gram overlaps of lower order it contains.
Consider using lower n-gram order or use SmoothingFunction()
warnings.warn(_msg)
/usr/local/lib/python3.6/dist-packages/nltk/translate/bleu_score.py:516: UserWarning:
The hypothesis contains 0 counts of 3-gram overlaps.
Therefore the BLEU score evaluates to 0, independently of
how many N-gram overlaps of lower order it contains.
Consider using lower n-gram order or use SmoothingFunction()
warnings.warn(_msg)
/usr/local/lib/python3.6/dist-packages/nltk/translate/bleu_score.py:516: UserWarning:
The hypothesis contains 0 counts of 4-gram overlaps.
Therefore the BLEU score evaluates to 0, independently of
how many N-gram overlaps of lower order it contains.
Consider using lower n-gram order or use SmoothingFunction()
warnings.warn(_msg)
1.331960397810445e-231
sentence_bleu(ref, sentence, smoothing_function=SmoothingFunction().method2)
0.20556680845025987