Skip to content

fix: lazy-load NLTK resources to eliminate startup overhead - #1122

Merged
steam-bell-92 merged 1 commit into
steam-bell-92:mainfrom
Tech4Aditya:main
Jun 12, 2026
Merged

fix: lazy-load NLTK resources to eliminate startup overhead#1122
steam-bell-92 merged 1 commit into
steam-bell-92:mainfrom
Tech4Aditya:main

Conversation

@Tech4Aditya

Copy link
Copy Markdown
Contributor

📝 Description

Fixes the startup overhead caused by unconditional nltk.download() calls at module import time.

Replaced the two bare top-level calls:

nltk.download('punkt')
nltk.download('stopwords')

with a _ensure_nltk_resources() helper that uses nltk.data.find() to check if each resource is already present before downloading. The helper is called lazily inside analyze_resume(), so downloads only happen when the function is actually invoked — and only if the resource is missing.

Changes made:

  • Removed nltk.download('punkt') and nltk.download('stopwords') from module level
  • Added _ensure_nltk_resources() with LookupError guard for punkt, punkt_tab, and stopwords
  • Called _ensure_nltk_resources() as the first line of analyze_resume()

🔗 Linked Issue

Closes #1000


📋 Contribution Checklist

  • My code strictly adheres to the project guidelines (Standard library only, procedural code, clean spacing).
  • I have verified that my files are placed in the correct directory.
  • I have tested my changes thoroughly on my local machine.
  • I have included interactive emojis and clean console/UI outputs.
  • GSSoC 2026: I have been formally assigned to this issue and noted it above.

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@Tech4Aditya is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Tech4Aditya

Copy link
Copy Markdown
Contributor Author

The CI failure in modal.spec.js is unrelated to this PR . it tests
focus-trapping behaviour in the web-apps modal component, which I haven't
touched. This test appears to be failing on main independently of these changes.

@steam-bell-92 steam-bell-92 added type:bug Something isn't working level:beginner gssoc:approved GSSoC 2026 approving tag labels Jun 12, 2026
@steam-bell-92
steam-bell-92 merged commit bbcbe6c into steam-bell-92:main Jun 12, 2026
9 of 11 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution!

Your Pull Request has been merged successfully.

We appreciate the time and effort you put into improving this project. Contributions like yours help the repository grow and stay useful for everyone.

If you'd like to contribute again, please check the open issues and make sure you are assigned before opening another Pull Request.

Thanks again for your support! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC 2026 approving tag level:beginner type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: NLTK resources are downloaded during module import causing unnecessary startup overhead

2 participants