generated from HephaestusProject/template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
44 lines (30 loc) · 1.09 KB
/
main.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""CharLM: Character-Aware Neural Language Models
Usage:
main.py <command> [<args>...]
main.py (-h | --help)
Available commands:
build-vocabulary
train
predict
test
Options:
-h --help Show this.
See 'python main.py <command> --help' for more information on a specific command.
"""
from pathlib import Path
from type_docopt import docopt
from utils import IntList
if __name__ == "__main__":
args = docopt(__doc__, options_first=True)
argv = [args["<command>"]] + args["<args>"]
if args["<command>"] == "build-vocabulary":
from build_vocabulary import __doc__, build_vocabulary
build_vocabulary(docopt(__doc__, argv=argv, types={"path": Path}))
elif args["<command>"] == "train":
from train import __doc__, train
train(docopt(__doc__, argv=argv, types={"path": Path, "IntList": IntList}))
elif args["<command>"] == "test":
from test import __doc__, test
test(docopt(__doc__, argv=argv, types={"path": Path}))
else:
raise NotImplementedError(f"Command does not exist: {args['<command>']}")