Skip to content

Instantly share code, notes, and snippets.

View vignesh-kumar19's full-sized avatar

Vignesh Kumar Koraki vignesh-kumar19

View GitHub Profile
@vignesh-kumar19
vignesh-kumar19 / bleu.py
Created September 20, 2019 06:46 — forked from odashi/bleu.py
BLEU calculator
# usage (single sentence):
# ref = ['This', 'is', 'a', 'pen', '.']
# hyp = ['There', 'is', 'a', 'pen', '.']
# stats = get_bleu_stats(ref, hyp)
# bleu = calculate_bleu(stats) # => 0.668740
#
# usage (multiple sentences):
# stats = defaultdict(int)
# for ref, hyp in zip(refs, hyps):
# for k, v in get_bleu_stats(ref, hyp).items():