- Notifications
You must be signed in to change notification settings - Fork395
Agregar script para crear dict.txt#1059
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
""" | ||
Script to generate the 'dict.txt' dictionary based | ||
on the custom dictionaries under the 'dictionaries/' directory, | ||
but also considering the old words from the 'dict' file. | ||
This was done with: | ||
awk 1 dict dictionaries/*.txt > dict.txt | ||
but the problem was that windows users, not using Git bash | ||
have the problem that 'awk' is not a valid command, so this | ||
enable them to use the script instead. | ||
""" | ||
entries = set() | ||
# Read custom dictionaries | ||
for filename in Path("dictionaries").glob("*.txt"): | ||
with open(filename, "r") as f: | ||
lines = [i.rstrip() for i in f.readlines()] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Que te parece hacerlo case insensitive?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Lo habíamos discutido antes de implementar lo de | ||
if lines: | ||
entries.update(set(lines)) | ||
del lines | ||
# Remove empty string, from empty lines | ||
entries.remove("") | ||
# Read main 'dict' | ||
with open("dict", "r") as f: | ||
entries.update(set(i.rstrip() for i in f.readlines())) | ||
# Write the 'dict.txt' file | ||
with open("dict.txt", "w") as f: | ||
for e in entries: | ||
f.write(e) | ||
f.write("\n") | ||
print("Created 'dict.txt'") |
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.