2020-09-12 14:42:10 +03:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
2020-09-12 16:16:01 +03:00
|
|
|
|
# USAGE preprocess.sh source-langid target-langid spmodel [noflags] < input > output
|
2020-09-12 14:42:10 +03:00
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# replace SPMENCODE with your own setup!
|
|
|
|
|
|
|
|
|
|
if [ `hostname -d` == "bullx" ]; then
|
|
|
|
|
APPLHOME=/projappl/project_2001569
|
|
|
|
|
SPMENCODE=${APPLHOME}/marian-dev/build-spm/spm_encode
|
|
|
|
|
else
|
|
|
|
|
SPMENCODE=`which spm_encode || echo "${PWD}/tools/marian-dev/build/spm_encode"`
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$4" == "noflags" ]; then
|
|
|
|
|
sed -e 's/,/,/g' \
|
|
|
|
|
-e 's/。 */. /g' \
|
|
|
|
|
-e 's/、/,/g' \
|
|
|
|
|
-e 's/”/"/g' \
|
|
|
|
|
-e 's/“/"/g' \
|
|
|
|
|
-e 's/∶/:/g' \
|
|
|
|
|
-e 's/:/:/g' \
|
|
|
|
|
-e 's/?/\?/g' \
|
|
|
|
|
-e 's/《/"/g' \
|
|
|
|
|
-e 's/》/"/g' \
|
|
|
|
|
-e 's/)/\)/g' \
|
|
|
|
|
-e 's/!/\!/g' \
|
|
|
|
|
-e 's/(/\(/g' \
|
|
|
|
|
-e 's/;/;/g' \
|
|
|
|
|
-e 's/1/"/g' \
|
|
|
|
|
-e 's/」/"/g' \
|
|
|
|
|
-e 's/「/"/g' \
|
|
|
|
|
-e 's/0/0/g' \
|
|
|
|
|
-e 's/3/3/g' \
|
|
|
|
|
-e 's/2/2/g' \
|
|
|
|
|
-e 's/5/5/g' \
|
|
|
|
|
-e 's/6/6/g' \
|
|
|
|
|
-e 's/9/9/g' \
|
|
|
|
|
-e 's/7/7/g' \
|
|
|
|
|
-e 's/8/8/g' \
|
|
|
|
|
-e 's/4/4/g' \
|
|
|
|
|
-e 's/. */. /g' \
|
|
|
|
|
-e 's/~/\~/g' \
|
|
|
|
|
-e "s/’/\'/g" \
|
|
|
|
|
-e 's/…/\.\.\./g' \
|
|
|
|
|
-e 's/━/\-/g' \
|
|
|
|
|
-e 's/〈/\</g' \
|
|
|
|
|
-e 's/〉/\>/g' \
|
|
|
|
|
-e 's/【/\[/g' \
|
|
|
|
|
-e 's/】/\]/g' \
|
|
|
|
|
-e 's/%/\%/g' |
|
|
|
|
|
perl -C -pe 's/\p{C}/ /g;' |
|
|
|
|
|
sed 's/ */ /g;s/^ *//g;s/ *$//g' |
|
|
|
|
|
${SPMENCODE} --model $3
|
|
|
|
|
else
|
|
|
|
|
sed -e 's/,/,/g' \
|
|
|
|
|
-e 's/。 */. /g' \
|
|
|
|
|
-e 's/、/,/g' \
|
|
|
|
|
-e 's/”/"/g' \
|
|
|
|
|
-e 's/“/"/g' \
|
|
|
|
|
-e 's/∶/:/g' \
|
|
|
|
|
-e 's/:/:/g' \
|
|
|
|
|
-e 's/?/\?/g' \
|
|
|
|
|
-e 's/《/"/g' \
|
|
|
|
|
-e 's/》/"/g' \
|
|
|
|
|
-e 's/)/\)/g' \
|
|
|
|
|
-e 's/!/\!/g' \
|
|
|
|
|
-e 's/(/\(/g' \
|
|
|
|
|
-e 's/;/;/g' \
|
|
|
|
|
-e 's/1/"/g' \
|
|
|
|
|
-e 's/」/"/g' \
|
|
|
|
|
-e 's/「/"/g' \
|
|
|
|
|
-e 's/0/0/g' \
|
|
|
|
|
-e 's/3/3/g' \
|
|
|
|
|
-e 's/2/2/g' \
|
|
|
|
|
-e 's/5/5/g' \
|
|
|
|
|
-e 's/6/6/g' \
|
|
|
|
|
-e 's/9/9/g' \
|
|
|
|
|
-e 's/7/7/g' \
|
|
|
|
|
-e 's/8/8/g' \
|
|
|
|
|
-e 's/4/4/g' \
|
|
|
|
|
-e 's/. */. /g' \
|
|
|
|
|
-e 's/~/\~/g' \
|
|
|
|
|
-e "s/’/\'/g" \
|
|
|
|
|
-e 's/…/\.\.\./g' \
|
|
|
|
|
-e 's/━/\-/g' \
|
|
|
|
|
-e 's/〈/\</g' \
|
|
|
|
|
-e 's/〉/\>/g' \
|
|
|
|
|
-e 's/【/\[/g' \
|
|
|
|
|
-e 's/】/\]/g' \
|
|
|
|
|
-e 's/%/\%/g' |
|
|
|
|
|
perl -C -pe 's/\p{C}/ /g;' |
|
|
|
|
|
sed 's/ */ /g;s/^ *//g;s/ *$//g' |
|
|
|
|
|
${SPMENCODE} --model $3 |
|
|
|
|
|
sed "s/^/>>$2<< /"
|
|
|
|
|
fi
|
|
|
|
|
|