-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-hunspell.sh
executable file
·81 lines (66 loc) · 2.87 KB
/
build-hunspell.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
dir_programes="fdic-to-hunspell"
dir_dades="$dir_programes/dades"
dir_intermedi="$dir_programes/intermedi"
dir_arrel="diccionari-arrel"
dir_resultat="resultats/hunspell"
VERSION="9.9.9"
YEAR=$(date "+%Y")
MYDATE=$(date "+%d-%m-%Y")
while getopts "v:" opt; do
case "$opt" in
v) VERSION=$OPTARG;
;;
esac
done
echo $VERSION
cd diccionari-arrel
./sort-all.sh
cd ..
for variant in catalan catalan-valencia
do
echo "*** Generant diccionari: $variant"
mkdir $dir_intermedi
echo "Generant fitxers d'afixos"
perl $dir_programes/genera-afixos-hunspell.pl $dir_dades/regles.hunspell $dir_intermedi/afixos-no-verbs.aff -$variant
perl $dir_programes/genera-modelsverbals-hunspell.pl $dir_arrel/models-verbals $dir_intermedi/modelsverbals.aff -$variant
echo "Generant diccionari de verbs"
perl $dir_programes/fdic-to-hunspell-verbs.pl $dir_arrel/verbs-fdic.txt $dir_intermedi/verbs.dic $dir_arrel/models-verbals -$variant
echo "Generant diccionari de noms i adjectius"
perl $dir_programes/fdic-to-hunspell-noms-adj.pl $dir_arrel $dir_intermedi $dir_dades/regles.hunspell -$variant
echo "Generant diccionari de la resta de categories"
perl $dir_programes/fdic-to-hunspell-resta.pl $dir_arrel $dir_intermedi/resta.dic -$variant
#cp $dir_dades/*.dic $dir_intermedi
cp $dir_dades/*.aff $dir_intermedi
cat $dir_intermedi/*.dic > $dir_intermedi/$variant.dic
#Fes les exclusions
echo "Fent exclusions"
perl $dir_programes/fes-exclusions.pl $dir_dades/exclusions.txt $dir_intermedi/$variant.dic $dir_intermedi/$variant-exclusions.dic
#Afegeix extres després d'exclusions (per a "ens")
cat $dir_dades/extres.dic $dir_intermedi/$variant-exclusions.dic > $dir_intermedi/$variant-exclusions-extres.dic
# Copia informacio de copyright
cp $dir_dades/copyright.txt $dir_intermedi
sed -i -r 's/^(.*)$/# \1/' $dir_intermedi/copyright.txt
sed -i -e s/\#\#VERSION\#\#/$VERSION/ $dir_intermedi/copyright.txt
sed -i -e s/\#\#YEAR\#\#/$YEAR/ $dir_intermedi/copyright.txt
sed -i -e s/\#\#DATE\#\#/$MYDATE/ $dir_intermedi/copyright.txt
cd $dir_intermedi
export LC_ALL=C && sort -u $variant-exclusions-extres.dic -o $variant.dic
sed '/^$/d' -i $variant.dic
cat $variant.dic | wc -l > linies.txt
cat linies.txt $variant.dic > tmp.dic
rm $variant.dic
mv tmp.dic $variant.dic
cat copyright.txt header.aff afixos-no-verbs.aff model_cantar_sense_apostrofacio.aff modelsverbals.aff > $variant.aff
cd -
#Converteix a terminacions DOS
sed -i 's/$/\r/' $dir_intermedi/$variant.dic
sed -i 's/$/\r/' $dir_intermedi/$variant.aff
#Mou al directori de resultats
rm $dir_resultat/$variant.*
cp $dir_intermedi/$variant.* $dir_resultat
#Elimina fitxers intermedis
rm -rf $dir_intermedi
echo "Per a fer un test: hunspell -d $variant"
done
echo "FET. Resultats en $dir_resultat"