Ожидаемый тип для hypothesis
- list(str)
, из документация :
: гипотеза типа: список (str)
candidate
- это list(list(str))
, вы можете вычислить bleu_score следующим образом:
from nltk.translate.bleu_score import sentence_bleu
references = [['two', 'passenger', 'planes', 'on', 'a', 'grassy', 'plain'],
['An', 'airplane', 'sitting', 'on', 'the', 'tarmac', 'at', 'an', 'airport', 'with', 'another', 'plane',
'in', 'the', 'background', '.'],
['A', 'white', 'an', 'blue', 'airplane', 'parked', 'at', 'the', 'airport', 'near', 'another', 'small',
'plane', '.'], ['Blue', 'and', 'white', 'airplane', 'parked', '.'],
['two', 'airplanes', 'are', 'waiting', 'on', 'the', 'tarmac'],
['Two', 'airplanes', 'parked', 'at', 'the', 'airport', '.'],
['A', 'passenger', 'aircraft', 'with', 'landing', 'gear', 'down', '.'],
['A', 'passenger', 'jet', 'flies', 'through', 'the', 'air', '.'],
['A', 'passenger', 'plane', 'fly', 'through', 'the', 'sky', '.'],
['The', 'Austrian', 'plane', 'soars', 'in', 'the', 'sky', '.']]
candidates = [
['An', 'airplane', 'sitting', 'on', 'the', 'tarmac', 'at', 'an', 'airport', 'with', 'another', 'plane', 'in', 'the',
'background', '.'], ['A', 'passenger', 'jet', 'flies', 'through', 'the', 'air', '.']]
for candidate in candidates:
print(sentence_bleu(references, candidate))
выход
1.0
1.0