use dictionaries from Aspell website
authorLaurent Mazet <mazet@softndesign.org>
Sun, 14 Jun 2020 14:26:24 +0000 (16:26 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Sun, 14 Jun 2020 14:26:24 +0000 (16:26 +0200)
dict-dists-extractor/Makefile

index f13a7ab00c12df208d4ed8b6eba913f5c2372c79..2ebba6cdac69573a92a59f4ae83e875cd560a9a6 100644 (file)
@@ -6,13 +6,16 @@ LANGS = bg ca da de en eo es fr it nl no pl pt sv uk
 # to add: ar br cs cy el et eu fi? ga he hr hu hy is lv ro ru sk sl
 #LANGS = af ar bg br ca cs cy da de el en eo es et eu fi fr ga he hr hu hy is it la lv ms nl no pl pt ro ru sk sl sv tr uk xk
 
+ASPDICT = https://ftp.gnu.org/gnu/aspell/dict/0index.html
+
 LOWS = $(addsuffix .low,$(LANGS))
 
 DICTS = $(addsuffix .dict,$(LANGS))
 
+DEPEND = Makefile
 MAKEFLAGS = -s
 
-all:
+all: src.mk
        make $(addprefix check-,$(LANGS))
 
 $(ROOT_DICT):
@@ -23,32 +26,45 @@ count:
 
 low: $(LOWS)
 
-INSTALL_ASPELL_DICT = apt search aspell-$(1) && \
-    ( dpkg -l aspell-$(1) | grep -q ^ii || sudo apt install aspell-$(1) )
 
-ASPELL_DUMP_MASTER = aspell -d $(1) dump master $(1) | \
-    aspell -l $(1) expand | \
+src.mk:
+       wget $(ASPDICT) -q -O - | \
+       awk 'BEGIN { base="'`dirname $(ASPDICT)`'" } \
+         /<tr><td><a/ { $$0 = gensub(/.*"(.+)".*"(.+)\/(.+)".*/, "\\1 \\2 \\3", "g"); \
+                        printf "%s.dir: %s\n\n", $$1, $$3; \
+                            printf "%s:\n\twget -q %s/%s/%s\n\n", $$3, base, $$2, $$3 } \
+         /<\/table>/ { exit }' > $@
+
+include $(wildcard src.mk)
+
+INSTALL_ASPELL_DICT = tar xjf $(1) && \
+    cd $(2) && \
+       ./configure && \
+       make
+
+ASPELL_DUMP_MASTER = aspell --dict-dir=$(2) -d $(1) dump master $(1) | \
+    aspell --dict-dir=$(2) -l $(1) expand | \
     tr -s '[:space:]' '\n' | \
     LC_ALL=C sort -S28G -u > $(1).low
 
-%.low:
+%.dir:
+       echo Installing $(@:.dir=) dictionary
+       $(call INSTALL_ASPELL_DICT,$<,$(<:.tar.bz2=))
+       mv $(<:.tar.bz2=) $@
+
+%.low: %.dir
        echo Building list of word $@
-       $(call INSTALL_ASPELL_DICT,$(@:.low=))
-       $(call ASPELL_DUMP_MASTER,$(@:.low=))
+       $(call ASPELL_DUMP_MASTER,$(<:.dir=),./$<)
 
 no.low:
-       echo Building list of word $@
-       $(call INSTALL_ASPELL_DICT,no)
-       $(call ASPELL_DUMP_MASTER,nb)
+       make nb.low
        mv nb.low $@
 
 pt.low:
-       echo Building list of word $@
-       $(call INSTALL_ASPELL_DICT,pt-pt)
-       $(call ASPELL_DUMP_MASTER,pt_PT)
+       make pt_PT.low
        mv pt_PT.low $@
 
-$(ROOT_DICT)/bg.dict: bg.low Makefile
+$(ROOT_DICT)/bg.dict: bg.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -58,7 +74,7 @@ $(ROOT_DICT)/bg.dict: bg.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/ca.dict: ca.low Makefile
+$(ROOT_DICT)/ca.dict: ca.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -74,7 +90,7 @@ $(ROOT_DICT)/ca.dict: ca.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/da.dict: da.low Makefile
+$(ROOT_DICT)/da.dict: da.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -89,7 +105,7 @@ $(ROOT_DICT)/da.dict: da.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/de.dict: de.low Makefile
+$(ROOT_DICT)/de.dict: de.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -103,7 +119,7 @@ $(ROOT_DICT)/de.dict: de.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/en.dict: en.low Makefile
+$(ROOT_DICT)/en.dict: en.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -119,7 +135,7 @@ $(ROOT_DICT)/en.dict: en.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/eo.dict: eo.low Makefile
+$(ROOT_DICT)/eo.dict: eo.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -128,7 +144,7 @@ $(ROOT_DICT)/eo.dict: eo.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/es.dict: es.low Makefile
+$(ROOT_DICT)/es.dict: es.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -142,7 +158,7 @@ $(ROOT_DICT)/es.dict: es.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/fr.dict: fr.low Makefile
+$(ROOT_DICT)/fr.dict: fr.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -157,7 +173,7 @@ $(ROOT_DICT)/fr.dict: fr.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/it.dict: it.low Makefile
+$(ROOT_DICT)/it.dict: it.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -172,7 +188,7 @@ $(ROOT_DICT)/it.dict: it.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/nl.dict: nl.low Makefile
+$(ROOT_DICT)/nl.dict: nl.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -188,7 +204,7 @@ $(ROOT_DICT)/nl.dict: nl.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/no.dict: no.low Makefile
+$(ROOT_DICT)/no.dict: no.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -204,7 +220,7 @@ $(ROOT_DICT)/no.dict: no.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/pl.dict: pl.low Makefile
+$(ROOT_DICT)/pl.dict: pl.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -220,7 +236,7 @@ $(ROOT_DICT)/pl.dict: pl.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/pt.dict: pt.low Makefile
+$(ROOT_DICT)/pt.dict: pt.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -234,7 +250,7 @@ $(ROOT_DICT)/pt.dict: pt.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/sv.dict: sv.low Makefile
+$(ROOT_DICT)/sv.dict: sv.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \
@@ -247,7 +263,7 @@ $(ROOT_DICT)/sv.dict: sv.low Makefile
         sort | \
         uniq > $@
 
-$(ROOT_DICT)/uk.dict: uk.low Makefile
+$(ROOT_DICT)/uk.dict: uk.low $(DEPEND)
        echo Building $@ from $<
        cat $< | \
         grep -v '^.$$' | \