f287a04243fb8cbe966161c106dce14fac274a6c,ch12/libbots/utils.py,,calc_bleu,#Any#Any#Any#,15
Before Change
for n in range(1, max_n_grams+1):
cand_ngrams = list(iterate_n_grams(cand_seq, n=n))
cand_counts = collections.Counter(cand_ngrams)
ref_counts = collections.Counter(iterate_n_grams(ref_seq, n=n))
for item, count in cand_counts.items():
if item in ref_counts:
score += min(count, ref_counts[item]) / len(cand_ngrams)
score /= max_n_grams
return score
After Change
// score /= min(max_n_grams, len(ref_seq))
// return score
return bleu_score.sentence_bleu(
[tuple(ref_seq)], cand_seq, [1/max_n_grams for _ in range(max_n_grams)])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: f287a04243fb8cbe966161c106dce14fac274a6c
Time: 2018-01-06
Author: max.lapan@gmail.com
File Name: ch12/libbots/utils.py
Class Name:
Method Name: calc_bleu
Project Name: dmlc/gluon-nlp
Commit Name: 043e3000ad4a59f434e1975f9f0f7c0ac9aead53
Time: 2018-04-22
Author: xshiab@ust.hk
File Name: scripts/nmt/bleu.py
Class Name:
Method Name: compute_bleu
Project Name: OpenNMT/OpenNMT-py
Commit Name: d556116728d4f505eb14be081f29e32212145725
Time: 2017-09-01
Author: bpeters@coli.uni-saarland.de
File Name: onmt/IO.py
Class Name:
Method Name: merge_vocabs