-
Notifications
You must be signed in to change notification settings - Fork 9
/
add-orphans.sh
148 lines (140 loc) · 4.63 KB
/
add-orphans.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
##
## download the orphans
##
## convert to LMF
##
## read into the OMW.db
##
OMWROOT="$( cd "$( dirname "$0" )"; echo "$PWD" )"
RESDIR="$OMWROOT/omw/resources"
CITATIONFILE="omw-citations.tab"
mkdir -p log
### Orphans
# declare -A lngs=(\
# ["arb"]="arb" \
# ["slk"]="sk" \
# ["isl"]="is" \
# ["als"]="als" \
# ["arb"]="arb" \
# ["ell"]="el" \
# ["fra"]="fr" \
# ["heb"]="he" \
# ["hrv"]="hr" \
# ["lit"]="lt" \
# )
### Everything
declare -A lngs=(\
["als"]="als" \
["arb"]="arb" \
["bul"]="bg" \
["cmn"]="zh" \
# ["qcn"]="zh_Hant" \
["dan"]="da" \
["ell"]="el" \
# ["eng"]="en" \
# ["fas"]="fa" \
["fin"]="fi" \
["fra"]="fr" \
["heb"]="he" \
["hrv"]="hr" \
["isl"]="is" \
["ita"]="it" \
["jpn"]="jp" \
["cat"]="ca" \
["eus"]="eu" \
["glg"]="gl" \
["spa"]="es" \
["ind"]="id" \
["zsm"]="zsm" \
["nld"]="nl" \
["nno"]="nn" \
["nob"]="nb" \
["pol"]="pl" \
["por"]="pt" \
["ron"]="ro" \
["lit"]="lt" \
["slk"]="sk" \
["slv"]="sl" \
["swe"]="sv" \
["tha"]="th" \
)
#declare -A lngs=( ["als"]="als" )
cat <<EOT > wn_config.py
config.add_project('iwn', 'Italian Wordnet', 'it')
config.add_project_version(
'iwn', '1.0+wn',
'http://192.168.1.81/~bond/omw1.0/iwn.xml',
'http://opendefinition.org/licenses/odc-by/',
)
EOT
for lng in "${!lngs[@]}"
do
echo Processing $lng \("${lngs[$lng]}"\)
mkdir -p ${RESDIR}/${lng}
### fetch
wget -nc -P ${RESDIR} http://compling.hss.ntu.edu.sg/omw/wns/${lng}.zip
### extract
if [ $lng = 'lit' ] ###
then
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip slk/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip slk/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip slk/README
### MCR
elif [ $lng = 'cat' ] || [ $lng = 'eus' ] || [ $lng = 'spa' ] || [ $lng = 'glg' ]
then
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip mcr/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip mcr/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip mcr/README
elif [ $lng = 'cmn' ] ### COW
then
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip cow/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip cow/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip cow/README
elif [ $lng = 'ind' ] || [ $lng = 'zsm' ] ### MSA
then
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip msa/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip msa/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip msa/README
elif [ $lng = 'nno' ] || [ $lng = 'nob' ] ### NOR
then
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip nor/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip nor/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip nor/README
else
unzip -j -o -d ${RESDIR} ${RESDIR}/${lng}.zip ${lng}/wn-data-${lng}.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip ${lng}/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip ${lng}/README
fi
grep -P "${lng}\t|${lng}," ${CITATIONFILE} | cut -f2 > ${RESDIR}/${lng}/citation.rst
### convert
python3 scripts/tsv2lmf.py ${lng}wn "${lngs[$lng]}" scripts/ili-map.tab ${RESDIR}/wn-data-${lng}.tab --version "1.0+omw" --citation=${RESDIR}/${lng}/citation.rst > ${RESDIR}/${lng}/${lng}wn.xml
### validate
xmlstarlet validate -e --dtd omw/db/WN-LMF.dtd ${RESDIR}/${lng}/${lng}wn.xml
tar --exclude=citation.rst --exclude=*~ -cf ${RESDIR}/${lng}.tar ${RESDIR}/${lng}/
xz -z ${RESDIR}/${lng}.tar
###
### config files
###
labelll=`grep " label=" ${RESDIR}/${lng}wn.xml`
labell="${labelll# label=\"}"
label="${labell%\" }"
licenseee=`grep " license=" ${RESDIR}/${lng}wn.xml`
licensee="${licenseee# license=\"}"
license="${licensee%\" }"
#echo $licenseee $licensee $license
cat << EOT >> wn_config.py
config.add_project('${lng}wn', '${label}', '${lngs[$lng]}')
config.add_project_version(
'${lng}wn', '1.0+wn',
'http://192.168.1.81/~bond/omw1.0/${lang}/${lng}wn.xml',
'${license}'
)g
EOT
done
### Second Italian Wordnet
mkdir -p ${RESDIR}/iwn
unzip -j -o -d ${RESDIR} ${RESDIR}/ita.zip iwn/wn-data-ita.tab
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip iwn/citation.bib
unzip -j -o -d ${RESDIR}/${lng} ${RESDIR}/${lng}.zip iwn/README
python3 scripts/tsv2lmf.py iwn "it" scripts/ili-map.tab ${RESDIR}/wn-data-ita.tab --version "1.0+omw" > ${RESDIR}/iwn/iwn.xml
xmlstarlet validate -e --dtd omw/db/WN-LMF.dtd ${RESDIR}/iwn/iwn.xml