-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_onmt.py
29 lines (22 loc) · 1.07 KB
/
run_onmt.py
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
from onmt.bin.preprocess import main as preprocess
from onmt.bin.translate import main as translate
from onmt.utils.parse import ArgumentParser
from onmt.bin.train import main as train
if __name__ == '__main__':
parser = ArgumentParser()
# Simply add an argument for preprocess, train, translate
mode = parser.add_mutually_exclusive_group()
mode.add_argument("--preprocess", dest='preprocess', action='store_true',
help="Activate to preprocess with OpenNMT")
mode.add_argument("--train", dest='train', action='store_true',
help="Activate to train with OpenNMT")
mode.add_argument("--translate", dest='translate', action='store_true',
help="Activate to translate with OpenNMT")
mode, remaining_args = parser.parse_known_args()
if mode.preprocess:
preprocess(remaining_args)
elif mode.train:
train(remaining_args)
elif mode.translate:
args = translate(remaining_args)
# TODO compute scores directly after the translation is done