0066f83bc6f9f3861119db2593c3007796d2056c,deeppavlov/metrics/bleu.py,,bleu,#Any#Any#,22

Before Change



@register_metric("bleu")
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])

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

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: OpenNMT/OpenNMT-py
Commit Name: 90e5b974a7173ab0bba0990a690e32f25f5b725a
Time: 2019-01-14
Author: benzurdopeters@gmail.com
File Name: tools/embeddings_to_torch.py
Class Name:
Method Name: get_vocabs


Project Name: uber/ludwig
Commit Name: 3e2f276459f976054b5c2ab8c55be994170345da
Time: 2020-08-27
Author: carlo.grisetti@dsgroup.it
File Name: ludwig/utils/defaults.py
Class Name:
Method Name: merge_with_defaults


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