- 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 from1 commit
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
Usuarios en Windows, que no utilizan Git bash no pueden generar elarchivo `dict.txt`, pues no tienen acceso al comando 'awk'.Si bien, la construcción de toda la documentación no es necesaria,este paso es importante incluso cuando se quiere hacer la verificaciónpospell a un archivo determinado, pues necesitamos el diccionariogeneral que incluye todas las variaciones de 'dictionaries/'y 'dict'.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
cmaureir marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
import sys | ||
""" | ||
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 name in os.listdir("dictionaries"): | ||
if name.endswith(".txt"): | ||
filename = os.path.join("dictionaries", name) | ||
with open(filename, "r") as f: | ||
lines = [i.rstrip() for i in f.readlines()] | ||
if lines: | ||
entries.update(set(lines)) | ||
del lines | ||
cmaureir marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# 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.