Handle a variable number of references per hypothesis
masterTo use a variable number of reference segments per hypothesis, you can replace a missing reference segment with either None or an empty string '' within the refs list.
When using this pattern, the metric signature returned by get_signature() will reflect this by setting nrefs:var instead of a fixed number.
from sacrebleu.metrics import BLEU
# The first sentence has no reference (using empty string)
refs = [
['', 'It was not unexpected.', 'The man bit him first.'],
['The dog had bit the man.', 'No one was surprised.', 'The man had bitten the dog.'],
]
sys = ['The dog bit the man.', "It wasn't surprising.", 'The man had just bitten him.']
bleu = BLEU()
bleu.corpus_score(sys, refs)
# Signature will show nrefs:var
print(bleu.get_signature())