generated from simonw/click-app-template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this comment I have rewritten lexgo to use an external grep comman…
…d process for word search. It is not much faster and simpler. I also added support for spanish, french, portuguese, and german
- Loading branch information
Showing
9 changed files
with
2,290,185 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import lexgo.trie | ||
import importlib.resources | ||
import pathlib | ||
|
||
# Global Constants | ||
ENGLISH_DICT_PATH = "eng_words_alpha.txt" | ||
|
||
# Global Variables | ||
dictionary = lexgo.trie.Node("", False) | ||
|
||
def load(): | ||
dictionary_path = ENGLISH_DICT_PATH | ||
data_file = pathlib.Path(__file__).parent.joinpath("data", dictionary_path) | ||
with open(data_file) as f: | ||
# Read the dictionary file into a list | ||
words = list(f) | ||
lexgo.trie.setup(words, dictionary) | ||
DATA_DIR_NAME = "data" | ||
DICT_PATHS = { | ||
"en" : pathlib.Path(__file__).parent.joinpath(DATA_DIR_NAME, "en.txt").absolute().as_posix(), | ||
"es" : pathlib.Path(__file__).parent.joinpath(DATA_DIR_NAME, "es.txt").absolute().as_posix(), | ||
"fr" : pathlib.Path(__file__).parent.joinpath(DATA_DIR_NAME, "fr.txt").absolute().as_posix(), | ||
"pt" : pathlib.Path(__file__).parent.joinpath(DATA_DIR_NAME, "pt.txt").absolute().as_posix(), | ||
"de" : pathlib.Path(__file__).parent.joinpath(DATA_DIR_NAME, "de.txt").absolute().as_posix() | ||
} |
Oops, something went wrong.