f287a04243fb8cbe966161c106dce14fac274a6c,ch12/libbots/utils.py,,calc_bleu,#Any#Any#Any#,15
Before Change
:param ref_seq:
:return:
score = 0.0
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: 4
Non-data size: 6
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: deepmind/dm_control
Commit Name: 3301c738b7b48f979f4495f2fea2726d94722539
Time: 2020-02-18
Author: jsmerel@google.com
File Name: dm_control/locomotion/tasks/random_goal_maze.py
Class Name: RepeatSingleGoalMazeAugmentedWithTargets
Method Name: __init__
Project Name: nipy/dipy
Commit Name: 824a577e1148415744001dde2309c8744d636c54
Time: 2014-02-07
Author: demian.wassermann@inria.fr
File Name: dipy/reconst/shore.py
Class Name: ShoreFit
Method Name: pdf_grid
Project Name: jonathf/chaospy
Commit Name: fde4b1f40f02082b56e8af3c696b3f1b0cef7fa4
Time: 2017-09-30
Author: jonathf@gmail.com
File Name: src/chaospy/poly/collection/core.py
Class Name:
Method Name: variable