-
-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include stop word lists from Lucene and the Snowball project (#1666)
- Loading branch information
1 parent
3e9c806
commit a4b759d
Showing
6 changed files
with
2,243 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import requests | ||
|
||
LANGUAGES = [ | ||
"danish", | ||
"dutch", | ||
"finnish", | ||
"french", | ||
"german", | ||
"italian", | ||
"norwegian", | ||
"portuguese", | ||
"russian", | ||
"spanish", | ||
"swedish", | ||
] | ||
|
||
with requests.Session() as sess, open("stopwords.rs", "w") as mod: | ||
mod.write("/*\n") | ||
mod.write( | ||
"These stop word lists are from the Snowball project (https://snowballstem.org/)\nwhich carries the following copyright and license:\n\n" | ||
) | ||
|
||
resp = sess.get( | ||
"https://raw.githubusercontent.com/snowballstem/snowball/master/COPYING" | ||
) | ||
resp.raise_for_status() | ||
mod.write(resp.text) | ||
mod.write("*/\n\n") | ||
|
||
for lang in LANGUAGES: | ||
resp = sess.get(f"https://snowballstem.org/algorithms/{lang}/stop.txt") | ||
resp.raise_for_status() | ||
|
||
mod.write(f"pub const {lang.upper()}: &[&str] = &[\n") | ||
|
||
for line in resp.text.splitlines(): | ||
line, _, _ = line.partition("|") | ||
|
||
for word in line.split(): | ||
mod.write(f' "{word}",\n') | ||
|
||
mod.write("];\n\n") |
This file contains 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
Oops, something went wrong.