-
Notifications
You must be signed in to change notification settings - Fork 1
/
BPE_split.sh
executable file
·59 lines (48 loc) · 1.27 KB
/
BPE_split.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
#!/usr/bin/env bash
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
set -e
# Read arguments
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--src)
SRC="$2"; shift 2;;
--tgt)
TGT="$2"; shift 2;;
--lang)
LANG="$2"; shift 2;;
--input)
INP="$2"; shift 2;;
--output)
OUTP="$2"; shift 2;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
# Check parameters
if [ "$SRC" == "" ]; then echo "--src not provided"; exit; fi
if [ "$TGT" == "" ]; then echo "--tgt not provided"; exit; fi
if [ "$SRC" == "$TGT" ]; then echo "source and target cannot be identical"; exit; fi
if [ "$INP" == "" ]; then echo "--input not provided"; exit; fi
if [ "$OUTP" == "" ]; then echo "--output not provided"; exit; fi
# Initialize tools and data paths
PROC_PATH=./data/$SRC-$TGT-wmt
TOOLS_PATH=$PWD/tools
DATA_PATH=./data/$SRC-wmt
FASTBPE=$TOOLS_PATH/fastBPE/fast
BPE_JOINT_CODES=$PROC_PATH/codes.$TGT-$SRC
BPE_CODES_HMR=$DATA_PATH/codes.$SRC
if [ "$LANG" == "de" ];
then $FASTBPE applybpe $OUTP $INP $BPE_CODES_HMR ; fi
if [ "$LANG" == "hsb" ];
then $FASTBPE applybpe $OUTP $INP $BPE_JOINT_CODES ; fi