(refs, eff=None, n=4)
return (reflen, maxcounts)
Takes a list of reference sentences for a single segment
    and returns an object that encapsulates everything that BLEU
    needs to know about them.
Takes a list of reference sentences for a single segment
    and returns an object that encapsulates everything that BLEU
    needs to know about them.
Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them .
def cook_refs(refs, eff=None, n=4): ## lhuang: oracle will call with "average"
    '''Takes a list of reference sentences for a single segment
    and returns an object that encapsulates everything that BLEU
    needs to know about them.'''

    reflen = []
    maxcounts = {}
    for ref in refs:
        rl, counts = precook(ref, n)
        reflen.append(rl)
        for (ngram,count) in counts.iteritems():
            maxcounts[ngram] = max(maxcounts.get(ngram,0), count)

    # Calculate effective reference sentence length.
    if eff == "shortest":
        reflen = min(reflen)
    elif eff == "average":
        reflen = float(sum(reflen))/len(reflen)

    ## lhuang: N.B.: leave reflen computaiton to the very end!!
    
    ## lhuang: N.B.: in case of "closest", keep a list of reflens!! (bad design)

    return (reflen, maxcounts)
def cook_refs ( refs , eff = None , n = 4 ) : ## lhuang: oracle will call with "average" reflen = [ ] maxcounts = { } for ref in refs : rl , counts = precook ( ref , n ) reflen . append ( rl ) for ( ngram , count ) in counts . iteritems ( ) : maxcounts [ ngram ] = max ( maxcounts . get ( ngram , 0 ) , count ) # Calculate effective reference sentence length. if eff == "shortest" : reflen = min ( reflen ) elif eff == "average" : reflen = float ( sum ( reflen ) ) / len ( reflen ) ## lhuang: N.B.: leave reflen computaiton to the very end!! ## lhuang: N.B.: in case of "closest", keep a list of reflens!! (bad design) return ( reflen , maxcounts )