031a862a68853167c1be5aa971563f6069fd6d4d,nltk/translate/gleu_score.py,,sentence_gleu,#Any#Any#Any#Any#,16

Before Change


    // For each order of ngram, calculate the no. of ngram matches and
    // keep track of no. of ngram in references.
    ref_ngrams = Counter(everygrams(reference, min_len, max_len))
    hyp_ngrams = Counter(everygrams(hypothesis, min_len, max_len))
    overlap_ngrams = ref_ngrams & hyp_ngrams
    tp = sum(overlap_ngrams.values()) // True positives.
    tpfp = sum(hyp_ngrams.values()) // True positives + False positives.
    tpfn = sum(ref_ngrams.values()) // True positives + False negatives.

    // While defined as the minimum of precision and recall, we can
    // reduce the number of division operations by one by instead finding
    // the maximum of the denominators for the precision and recall
    // formulae, since the numerators are the same:
    //     precision = tp / tpfp
    //     recall = tp / tpfn
    //     min(precision, recall) == tp / max(tpfp, tpfn)

    return tp / max(tpfp, tpfn)


def corpus_gleu(references, hypotheses, min_len=1, max_len=4):
    

After Change


    if not references or isinstance(references[0], string_types):
        references = [references]

    return corpus_gleu(
        [references],
        [hypothesis],
        min_len=min_len,
        max_len=max_len
    )

def corpus_gleu(list_of_references, hypotheses, min_len=1, max_len=4):
    
    Calculate a single corpus-level GLEU score (aka. system-level GLEU) for all
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: nltk/nltk
Commit Name: 031a862a68853167c1be5aa971563f6069fd6d4d
Time: 2017-04-13
Author: goodman.m.w@gmail.com
File Name: nltk/translate/gleu_score.py
Class Name:
Method Name: sentence_gleu


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: miso-belica/sumy
Commit Name: 54157d4915902da0fb79f8fd7fdfafe536343c0f
Time: 2013-03-18
Author: miso.belica@gmail.com
File Name: sumy/algorithms/luhn.py
Class Name: LuhnMethod
Method Name: _get_significant_words