Skip to content
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

added json format words and Python example program #22

Merged
merged 2 commits into from
Oct 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ Files you may be interested in:

- [words.txt](words.txt) contains all words.
- [words_alpha.txt](words_alpha.txt) contains only [[:alpha:]] words. If you want a quick solution choose this.
- [words_dictionary.json](words_dictionary.json) contains all the words from words_alpha.txt as json format.
If you are using Python, you can easily load this file and use as a dictionary for faster performance. All the words are assigned with 1 in the dictionary.
See [read_english_dictionary.py](read_english_dictionary.py) for example usage.

16 changes: 16 additions & 0 deletions read_english_dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import json
import os, sys

def load_words():
try:
filename = os.path.dirname(sys.argv[0])+"\\"+"words_dictionary.json"
with open(filename,"r") as english_dictionary:
valid_words = json.load(english_dictionary)
return valid_words
except Exception as e:
return str(e)

if __name__ == '__main__':
english_words = load_words()
# demo print
print(english_words["fate"])
1 change: 1 addition & 0 deletions words_dictionary.json

Large diffs are not rendered by default.

Binary file added words_dictionary.zip
Binary file not shown.