0066f83bc6f9f3861119db2593c3007796d2056c,deeppavlov/metrics/bleu.py,,per_item_dialog_bleu,#Any#Any#,40
Before Change
@register_metric("per_item_dialog_bleu")
def per_item_dialog_bleu(y_true, y_predicted):
y_true = [y["text"] for dialog in y_true for y in dialog]
y_predicted = itertools.chain(*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.
After Change
@register_metric("per_item_dialog_bleu")
def per_item_dialog_bleu(y_true, y_predicted):
y_true = (y["text"] for dialog in y_true for y in dialog)
return corpus_bleu([[y_t.lower().split()] for y_t in y_true],
[y_p.lower().split() for y_p in y_predicted])
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
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: per_item_dialog_bleu
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: per_item_bleu
Project Name: OpenNMT/OpenNMT-py
Commit Name: 3fc1db7454bfe9e378dc7a8f321ac22dfe8b0ea7
Time: 2017-09-12
Author: bpeters@coli.uni-saarland.de
File Name: onmt/Loss.py
Class Name:
Method Name: shards