Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word_count_mean of COCO Caption #46

Closed
moiSusu opened this issue Jan 10, 2024 · 1 comment
Closed

word_count_mean of COCO Caption #46

moiSusu opened this issue Jan 10, 2024 · 1 comment

Comments

@moiSusu
Copy link

moiSusu commented Jan 10, 2024

How is the "word_count_mean" in the COCO Caption results computed? I can't find it in the scripts.

@kennymckormick
Copy link
Member

Hi, @moiSusu , word_count_mean is counted based on the prediction files of COCO_VAL, and the script is not included in this repo. Below is the function we used for word counting, in case you need:

def word_count(inText):
    inText = str(inText)
    outText = inText
    punct = [';', r'/', '[', ']', '"', '{', '}', '(', ')', '=', '+', '\\', '_', '-', '>', '<', '@', '`', ',', '?', '!']
    commaStrip = re.compile('(\d)(,)(\d)')  # noqa: W605
    periodStrip = re.compile('(?!<=\d)(\.)(?!\d)')  # noqa: W605
    for p in punct:
        if (p + ' ' in inText or ' ' + p in inText) or (re.search(
                commaStrip, inText) is not None):
            outText = outText.replace(p, '')
        else:
            outText = outText.replace(p, ' ')
    outText = periodStrip.sub('', outText, re.UNICODE)
    return len(outText.split())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants