Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
cmaureir merged 4 commits intopython:3.8fromcmaureir:create_auto_dict
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
Agregar script para crear dict.txt
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
@cmaureir
cmaureir committedOct 11, 2020
commit9ba2e923f3aa5ef3c1a026bfcf4a2f4518a4e13d
4 changes: 2 additions & 2 deletions.overrides/faq.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,8 +26,8 @@ pospell. Pospell puede ser instalada en tu entorno de Python empleando pip
Una vez instalado, para chequear el fichero .po sobre el que estás trabajando,
ejecuta desde el directorio principal del repo::

awk 1 dict dictionaries/*.txt >dict.txt
pospell -p dict.txt -les_AR -les_ES path/tu_fichero.po
python scripts/create_dict.py # para crear el archivo 'dict.txt'
pospell -p dict.txt -l es_ES path/tu_fichero.po

pospell emplea la herramienta de diccionarios hunspell. Si pospell falla dando
como error que no tiene hunspell instalado, lo puedes instalar así:
Expand Down
4 changes: 2 additions & 2 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,8 +7,8 @@ repos:
hooks:
- id: merge-dicts
name: merge-dicts
entry: ./scripts/merge-dicts.sh
language:script
entry:python./scripts/create_dict.py
language:python
# This one requires package ``hunspell-es_es`` in Archlinux
- repo: https://github.com/JulienPalard/pospell
rev: v1.0.5
Expand Down
2 changes: 1 addition & 1 deletion.travis.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ install:
- powrap --version
script:
- powrap --check --quiet **/*.po
-awk 1 dict dictionaries/*.txt > dict.txt
-python scripts/create_dict.py
- pospell -p dict.txt -l es_AR -l es_ES **/*.po
- pip install -q -r requirements.txt
- PYTHONWARNINGS=ignore::FutureWarning sphinx-build -j auto -W --keep-going -b html -d cpython/Doc/_build/doctree -D language=es . cpython/Doc/_build/html
Expand Down
4 changes: 1 addition & 3 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,9 +89,7 @@ progress: venv

.PHONY: spell
spell: venv
# 'cat' tenia el problema que algunos archivos no tenían una nueva línea al final
# 'awk 1' agregará una nueva línea en caso que falte.
awk 1 dict dictionaries/*.txt > dict.txt
$(VENV)/bin/python scripts/create_dict.py
$(VENV)/bin/pospell -p dict.txt -l es_ES **/*.po


Expand Down
40 changes: 40 additions & 0 deletionsscripts/create_dict.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
import os
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

# 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'")
2 changes: 0 additions & 2 deletionsscripts/merge-dicts.sh
View file
Open in desktop

This file was deleted.


[8]ページ先頭

©2009-2025 Movatter.jp