-
Notifications
You must be signed in to change notification settings - Fork 6
/
preprocessing.sh
46 lines (41 loc) · 1.35 KB
/
preprocessing.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
echo 'Cloning Moses github repository (for tokenization scripts)...'
git clone https://github.com/moses-smt/mosesdecoder.git
echo 'Cloning WMT16 scripts...'
git clone https://github.com/rsennrich/wmt16-scripts.git
SCRIPTS=mosesdecoder/scripts
RO_SCRIPTS=wmt16-scripts
NORM_PUNC=$SCRIPTS/tokenizer/normalize-punctuation.perl
REM_NON_PRINT_CHAR=$SCRIPTS/tokenizer/remove-non-printing-char.perl
REPLACE_UNICODE_PUNCT=$SCRIPTS/tokenizer/replace-unicode-punctuation.perl
NORMALIZE_IU_SPELLING=normalize-iu-spelling.pl
REMOVE_DIACRITICS=$RO_SCRIPTS/remove-diacritics.py
NORMALIZE_ROMANIAN=$RO_SCRIPTS/normalise-romanian.py
if [ ${lang} == "zh" ]; then
cat ${infile} \
| ${REPLACE_UNICODE_PUNCT} \
| ${NORM_PUNC} -l ${lang} \
| ${REM_NON_PRINT_CHAR} \
| hanzi-convert - -s \
> ${outfile}
elif [ ${lang} == "ro" ]; then
cat ${infile} \
| ${REPLACE_UNICODE_PUNCT} \
| ${NORM_PUNC} -l ${lang} \
| ${REM_NON_PRINT_CHAR} \
| ${NORMALIZE_ROMANIAN} \
| ${REMOVE_DIACRITICS} \
> ${outfile}
elif [ ${lang} == "iu" ]; then
cat ${infile} \
| ${REPLACE_UNICODE_PUNCT} \
| ${NORM_PUNC} -l ${lang} \
| ${REM_NON_PRINT_CHAR} \
| perl ${NORMALIZE_IU_SPELLING} \
> ${outfile}
else
cat ${infile} \
| ${REPLACE_UNICODE_PUNCT} \
| ${NORM_PUNC} -l ${lang} \
| ${REM_NON_PRINT_CHAR} \
> ${outfile}
fi