File tree 6 files changed +43
-10
lines changed
6 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,8 @@ pospell. Pospell puede ser instalada en tu entorno de Python empleando pip
26
26
Una vez instalado, para chequear el fichero .po sobre el que estás trabajando,
27
27
ejecuta desde el directorio principal del repo::
28
28
29
- awk 1 dict dictionaries/*.txt > dict.txt
30
- pospell -p dict.txt -l es_AR -l es_ES path/tu_fichero.po
29
+ python scripts/create_dict.py # para crear el archivo ' dict.txt'
30
+ pospell -p dict.txt -l es_ES path/tu_fichero.po
31
31
32
32
pospell emplea la herramienta de diccionarios hunspell. Si pospell falla dando
33
33
como error que no tiene hunspell instalado, lo puedes instalar así:
Original file line number Diff line number Diff line change 7
7
hooks :
8
8
- id : merge-dicts
9
9
name : merge-dicts
10
- entry : ./scripts/merge-dicts.sh
11
- language : script
10
+ entry : python ./scripts/create_dict.py
11
+ language : python
12
12
# This one requires package ``hunspell-es_es`` in Archlinux
13
13
- repo : https://github.com/JulienPalard/pospell
14
14
rev : v1.0.5
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ install:
10
10
- powrap --version
11
11
script :
12
12
- powrap --check --quiet **/*.po
13
- - awk 1 dict dictionaries/*.txt > dict.txt
13
+ - python scripts/create_dict.py
14
14
- pospell -p dict.txt -l es_AR -l es_ES **/*.po
15
15
- pip install -q -r requirements.txt
16
16
- PYTHONWARNINGS=ignore::FutureWarning sphinx-build -j auto -W --keep-going -b html -d cpython/Doc/_build/doctree -D language=es . cpython/Doc/_build/html
Original file line number Diff line number Diff line change @@ -89,9 +89,7 @@ progress: venv
89
89
90
90
.PHONY : spell
91
91
spell : venv
92
- # 'cat' tenia el problema que algunos archivos no tenían una nueva línea al final
93
- # 'awk 1' agregará una nueva línea en caso que falte.
94
- awk 1 dict dictionaries/* .txt > dict.txt
92
+ $(VENV ) /bin/python scripts/create_dict.py
95
93
$(VENV ) /bin/pospell -p dict.txt -l es_ES ** /* .po
96
94
97
95
Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
3
+ """
4
+ Script to generate the 'dict.txt' dictionary based
5
+ on the custom dictionaries under the 'dictionaries/' directory,
6
+ but also considering the old words from the 'dict' file.
7
+
8
+ This was done with:
9
+ awk 1 dict dictionaries/*.txt > dict.txt
10
+ but the problem was that windows users, not using Git bash
11
+ have the problem that 'awk' is not a valid command, so this
12
+ enable them to use the script instead.
13
+ """
14
+
15
+ entries = set ()
16
+
17
+ # Read custom dictionaries
18
+ for filename in Path ("dictionaries" ).glob ("*.txt" ):
19
+ with open (filename , "r" ) as f :
20
+ lines = [i .rstrip () for i in f .readlines ()]
21
+ if lines :
22
+ entries .update (set (lines ))
23
+ del lines
24
+
25
+ # Remove empty string, from empty lines
26
+ entries .remove ("" )
27
+
28
+ # Read main 'dict'
29
+ with open ("dict" , "r" ) as f :
30
+ entries .update (set (i .rstrip () for i in f .readlines ()))
31
+
32
+ # Write the 'dict.txt' file
33
+ with open ("dict.txt" , "w" ) as f :
34
+ for e in entries :
35
+ f .write (e )
36
+ f .write ("\n " )
37
+ print ("Created 'dict.txt'" )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments