In the documentation of nltk.translate I can see it clearly that there is this
nltk.translate.bleu_score.sentence_bleu
function available for use. But when I use it for my script it shows the below error:
AttributeError: 'module' object has no attribute 'sentence_bleu'
Please suggest what mistake am I doing? or anything I missed in between.
For reference below is my sample code:
import nltk
hypothesis = ['It', 'is', 'a', 'cat', 'at', 'room']
reference = ['It', 'is', 'a', 'cat', 'inside', 'the', 'room']
BLEUscore = nltk.translate.bleu_score.sentence_bleu([reference], hypothesis)
This error occured due to the version of NLTK. This module is supported in NLTK 3.3 and above. Hava a look here
My NLTK version was 3.1