Fix wordsteam.py: Python 3 compatibility and polyglot HTTP 403 errors #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix wordsteam.py: Python 3 compatibility and polyglot HTTP 403 errors
Summary
This PR addresses two critical issues preventing Chapter 3's
wordsteam.pyscript from running:printstatements to use Python 3 parentheses syntaxThree solutions provided:
3_1_wordsteam.py): Python 3 compatible, but polyglot may still failpolyglot_downloader_patch.py): Adds User-Agent headers to help bypass server restrictions (may not fully resolve the issue)3_1_wordsteam_nltk_only.py): Recommended - Works reliably without polyglot dependencies, demonstrates Porter, Lancaster, and Snowball stemmersReview & Testing Checklist for Human
3_1_wordsteam.pyare complete (all print statements updated correctly)3_1_wordsteam_nltk_only.py) - This is the recommended solution and should work out of the box with justpip install nltkFIXES_README.md- Is it clear which solution users should choose? Does it adequately explain the polyglot issues?polyglot_downloader_patch.py) - It modifies an external library file. Consider whether this approach is appropriate or if we should just recommend the NLTK alternativeTest Plan
Notes
Known limitations:
Why the NLTK-only solution is recommended:
Session Info: