forked from modernmt/modernmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmt
executable file
·80 lines (64 loc) · 2.6 KB
/
mmt
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
#!/usr/bin/env python3
import sys
if not (sys.version_info.major == 3 and sys.version_info.minor > 5):
print("Wrong python version detected, required >= 3.6, but found %d.%d" %
(sys.version_info.major, sys.version_info.minor))
exit(1)
__description = '''\
ModernMT is a context-aware, incremental and distributed general purpose Neural Machine Translation technology
based on Transformer model.
ModernMT goal is to make MT easy to adopt and scale.
With ModernMT you don\'t need anymore to train multiple custom engines,
you can push all your data to a single engine that will automatically
and in real-time adapt to the context you provide.
ModernMT aims to deliver the quality of a custom engine and the low sparsity
of your all data combined.
You can find more information on: http://www.modernmt.eu/
'''
def main():
import argparse
from cli import CLIArgsException
from cli import cleaning, datagen, train, create, server, translate, evaluate, memory
actions = {
'clean': cleaning.main,
'datagen': datagen.main,
'train': train.main,
'create': create.main,
'start': server.main_start,
'stop': server.main_stop,
'status': server.main_status,
'translate': translate.main,
'evaluate': evaluate.main,
'memory': memory.main,
}
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=__description,
usage='%(prog)s [-h] ACTION [args]', add_help=False, prog='mmt')
parser.add_argument('action', metavar='ACTION', choices=actions.keys(), help='{%(choices)s}', nargs='?')
parser.add_argument('-h', '--help', dest='help', action='store_true', help='show this help message and exit')
argv = sys.argv[1:]
if len(argv) == 0:
parser.print_help()
exit(1)
command = argv[0]
args = argv[1:]
try:
if command in actions:
actions[command](args)
else:
parser.print_help()
exit(1)
except CLIArgsException as e:
message = '{prog}: error: {message}\n'.format(prog=e.parser.prog, message=e.message)
e.parser.print_usage(file=sys.stderr)
sys.stderr.write(message)
exit(1)
except KeyboardInterrupt:
sys.stderr.write('\nERROR Process Interrupted\n')
exit(1)
except Exception as e:
sys.stderr.write('\nERROR Unexpected exception: {message}\n'.format(message=str(e)))
exit(1)
if __name__ == '__main__':
from cli.mmt import MMT_JAR
sys.path.insert(0, MMT_JAR)
main()