0066f83bc6f9f3861119db2593c3007796d2056c,deeppavlov/metrics/bleu.py,,bleu,#Any#Any#,22
Before Change
def bleu(y_true, y_predicted):
examples_len = len(y_true)
bleu_list = (sentence_bleu([y2.lower().split()], y1.lower().split())\
for y1, y2 in zip(y_true, y_predicted))
return sum(bleu_list) / examples_len if examples_len else 0.
@register_metric("per_item_bleu")
def per_item_bleu(y_true, y_predicted):
if isinstance(y_true[0], (tuple, list)):
After Change
@register_metric("bleu")
def bleu(y_true, y_predicted):
if isinstance(y_true[0], (tuple, list)):
y_true = (y[0] for y in y_true)
return corpus_bleu([[y_t.lower().split()] for y_t in y_true],
[y_p.lower().split() for y_p in y_predicted])
@register_metric("google_bleu")
def google_bleu(y_true, y_predicted):
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 7
Instances
Project Name: deepmipt/DeepPavlov
Commit Name: 0066f83bc6f9f3861119db2593c3007796d2056c
Time: 2018-08-30
Author: mary.vikhreva@gmail.com
File Name: deeppavlov/metrics/bleu.py
Class Name:
Method Name: bleu
Project Name: keras-team/keras
Commit Name: 555ca942df407b8c1bf1d48383c60fa1bf09cc1d
Time: 2019-08-28
Author: francois.chollet@gmail.com
File Name: keras/utils/layer_utils.py
Class Name:
Method Name: count_params
Project Name: google/deepvariant
Commit Name: 73fb91173069179373f631a6f6119f46fc68393e
Time: 2019-11-12
Author: xunjieli@google.com
File Name: third_party/nucleus/util/variant_utils.py
Class Name:
Method Name: is_singleton