Skip to content

Reuse installed NLTK data for METEOR and word length - #901

Open
snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/reuse-local-nltk-data
Open

snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/reuse-local-nltk-data

Conversation

@snygginghani

Copy link
Copy Markdown

Summary

METEOR and word length currently call NLTK's downloader every time Evaluate loads the module, including when the required data is installed. A network failure can therefore disrupt local scoring.

Check local WordNet data and exercise the Punkt tokenizer first. Call the downloader only for an unavailable resource. Calling the tokenizer verifies availability with the installed NLTK version, including versions that require extracted Punkt files.

Validation

I preinstalled NLTK data from the official distribution and simulated an unavailable network by making nltk.download raise OSError. The unmodified setup called the downloader for both modules. With the patch, both modules loaded and scored actual text with zero downloader calls under NLTK 3.10.4.

python -m pytest tests/test_nltk_data_loading.py -q passed four cases covering installed and missing data for both modules. Black, isort, flake8 and git diff --check passed. The noisy progress output addressed by #726 remains a separate concern when a download is actually needed.

AI assistance was used to investigate and prepare the patch and tests.

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

Successfully merging this pull request may close these issues.

1 participant