-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Update stemming and Snowball #13561
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
Merged
Merged
Update stemming and Snowball #13561
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e3fd29c
Use the more modern English stemmer
AA-Turner b6c4578
Update URLs for the snowball stemmer project
AA-Turner da935e8
Add the generate_snowball script
AA-Turner b52df1b
Pre-parse stopwords
AA-Turner 17b17a6
Update Javascript to snowball 3.0.1
AA-Turner b025a3a
Remove node-specific bits
AA-Turner aaf9e07
Regenerate minified files
AA-Turner 9530c29
Use Snowball's english-stemmer.js
AA-Turner e0ee7d6
Docs
AA-Turner db62729
Simplify sphinx.search
AA-Turner 04f03aa
Merge branch 'master' into snowball/all
AA-Turner 892d28e
Refactor get_js_stemmer_code
AA-Turner 012a347
Merge branch 'master' into snowball/all
AA-Turner 2bb8549
CHANGES
AA-Turner 0a62a52
Merge branch 'master' into snowball/all
AA-Turner 5db1ca3
Merge branch 'master' into snowball/all
AA-Turner eb0b90f
sphinx.search
AA-Turner d0a598a
globalThis -> window
AA-Turner 9bccacd
Verify SHA256 digests
AA-Turner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,181 @@ | ||
# automatically generated by utils/generate-snowball.py | ||
# from https://snowballstem.org/algorithms/english/stop.txt | ||
|
||
from __future__ import annotations | ||
|
||
ENGLISH_STOPWORDS = frozenset({ | ||
'a', | ||
'about', | ||
'above', | ||
'after', | ||
'again', | ||
'against', | ||
'all', | ||
'am', | ||
'an', | ||
'and', | ||
'any', | ||
'are', | ||
"aren't", | ||
'as', | ||
'at', | ||
'be', | ||
'because', | ||
'been', | ||
'before', | ||
'being', | ||
'below', | ||
'between', | ||
'both', | ||
'but', | ||
'by', | ||
"can't", | ||
'cannot', | ||
'could', | ||
"couldn't", | ||
'did', | ||
"didn't", | ||
'do', | ||
'does', | ||
"doesn't", | ||
'doing', | ||
"don't", | ||
'down', | ||
'during', | ||
'each', | ||
'few', | ||
'for', | ||
'from', | ||
'further', | ||
'had', | ||
"hadn't", | ||
'has', | ||
"hasn't", | ||
'have', | ||
"haven't", | ||
'having', | ||
'he', | ||
"he'd", | ||
"he'll", | ||
"he's", | ||
'her', | ||
'here', | ||
"here's", | ||
'hers', | ||
'herself', | ||
'him', | ||
'himself', | ||
'his', | ||
'how', | ||
"how's", | ||
'i', | ||
"i'd", | ||
"i'll", | ||
"i'm", | ||
"i've", | ||
'if', | ||
'in', | ||
'into', | ||
'is', | ||
"isn't", | ||
'it', | ||
'near', | ||
"it's", | ||
'its', | ||
'itself', | ||
"let's", | ||
'me', | ||
'more', | ||
'most', | ||
"mustn't", | ||
'my', | ||
'myself', | ||
'no', | ||
'nor', | ||
'not', | ||
'of', | ||
'off', | ||
'on', | ||
'once', | ||
'only', | ||
'or', | ||
'other', | ||
'ought', | ||
'our', | ||
'ours', | ||
'ourselves', | ||
'out', | ||
'over', | ||
'own', | ||
'same', | ||
"shan't", | ||
'she', | ||
"she'd", | ||
"she'll", | ||
"she's", | ||
'should', | ||
"shouldn't", | ||
'so', | ||
'some', | ||
'such', | ||
'than', | ||
'that', | ||
"that's", | ||
'the', | ||
'their', | ||
'theirs', | ||
'them', | ||
'themselves', | ||
'then', | ||
'there', | ||
"there's", | ||
'these', | ||
'they', | ||
"they'd", | ||
"they'll", | ||
"they're", | ||
"they've", | ||
'this', | ||
'those', | ||
'through', | ||
'to', | ||
'too', | ||
'under', | ||
'until', | ||
'up', | ||
'very', | ||
'was', | ||
'will', | ||
"wasn't", | ||
'we', | ||
"we'd", | ||
"we'll", | ||
"we're", | ||
"we've", | ||
'were', | ||
"weren't", | ||
'what', | ||
"what's", | ||
'when', | ||
"when's", | ||
'where', | ||
"where's", | ||
'which', | ||
'while', | ||
'who', | ||
"who's", | ||
'whom', | ||
'why', | ||
"why's", | ||
'with', | ||
"won't", | ||
'would', | ||
"wouldn't", | ||
'you', | ||
"you'd", | ||
"you'll", | ||
"you're", | ||
"you've", | ||
'your', | ||
'yours', | ||
'yourself', | ||
'yourselves', | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want
word == ''
in here? From the docstring, that seems to indicate that empty-strings would be included in the index?(the test indices don't indicate any actual change in behaviour -- I'm not sure how an empty-string would be provided to the
_filter
function here..)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this has been marked as resolved, but I can answer the last part. It looks like this function gets called with both unstemmed words and their stems, and it's possible for get an empty string output from some stemmers for a non-empty input.
I would tend to argue that a well designed stemming algorithm should only produce an empty output for an empty input. However there have been a few cases where an algorithm can produce an empty stem for a certain non-empty input (or inputs). We've usually fixed these when they've come to light, but the original porter algorithm produces an empty stem for input
s
and given it's aiming to essentially be a reference implementation we have left that alone.I'm pretty confident you won't get an empty stem from "english". You may from other algorithms (but please report if you do).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we could/should add an info-level output message when we detect empty-string output from a stemmer, with a message indicating that it may be a Snowball bug.
(a warning message wouldn't be appropriate, because there isn't anything the user can do to fix it (and many Sphinx users run in strict mode, where warnings fail the build))
I'm leaning towards allowing the empty string values to reach the index file itself, because, provided that both Python and JS stemming is consistent, that seems marginally more correct behaviour-wise.