local_recall.py
def local_recall_scores(generated, ref_data):
    """
    Produce local recall score, given the generated descriptions and the references.
    """
    recalled = defaultdict(int)
    total = defaultdict(int)
    for image, references in ref_data.items():
        # Count the content words in each of the reference descriptions.
        word_counter = Counter()
        for reference in references:
            words = {word for word, tag in reference if content_pos(tag)}
            word_counter.update(words)
        # Create a set of generated words, based on the generated description.
        generated_words = set(generated[image])
        # Loop over the words, and their counts in the reference data.
        for word, count in word_counter.items():
            # We categorize these words by their frequency in the references.
            # In other words: how many descriptions contain this word?
            # If a word is produced by more annotators, we consider it to be more important.
            total[count] += 1
            # Check whether the word was actually generated and, if so, update the count.
            if word in generated_words:
                recalled[count] += 1
    # The result is a fraction for each of the frequency classes, indicating the local retrieval score.
    return [float(recalled[count])/total[count] for count in [1,2,3,4,5]]

    Produce local recall score, given the generated descriptions and the references.
    
Produce local recall score, given the generated descriptions and the references.
Produce local recall score given the generated descriptions and the references .
def local_recall_scores(generated, ref_data):
    recalled = defaultdict(int)
    total = defaultdict(int)
    for image, references in ref_data.items():
        word_counter = Counter()
        for reference in references:
            words = {word for word, tag in reference if content_pos(tag)}
            word_counter.update(words)
        generated_words = set(generated[image])
        for word, count in word_counter.items():
            total[count] += 1
            if word in generated_words:
                recalled[count] += 1
    return [float(recalled[count])/total[count] for count in [1,2,3,4,5]]
def local_recall_scores ( generated , ref_data ) : recalled = defaultdict ( int ) total = defaultdict ( int ) for image , references in ref_data . items ( ) : word_counter = Counter ( ) for reference in references : words = { word for word , tag in reference if content_pos ( tag ) } word_counter . update ( words ) generated_words = set ( generated [ image ] ) for word , count in word_counter . items ( ) : total [ count ] += 1 if word in generated_words : recalled [ count ] += 1 return [ float ( recalled [ count ] ) / total [ count ] for count in [ 1 , 2 , 3 , 4 , 5 ] ]
Produce local recall score, given the generated descriptions and the references.
Produce local recall score given the generated descriptions and the references .
"""
    Produce local recall score, given the generated descriptions and the references.
    """ # Count the content words in each of the reference descriptions. # Create a set of generated words, based on the generated description. # Loop over the words, and their counts in the reference data. # We categorize these words by their frequency in the references. # In other words: how many descriptions contain this word? # If a word is produced by more annotators, we consider it to be more important. # Check whether the word was actually generated and, if so, update the count. # The result is a fraction for each of the frequency classes, indicating the local retrieval score.
generated
ref_data