This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 531
/
Copy path__main__.py
48 lines (41 loc) · 1.56 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
45
46
47
48
import argparse
import textwrap
from . import (
clean_tok_corpus,
learn_subword,
apply_subword
)
SUBCOMMANDS = ['clean_tok_para_corpus', 'clean_tok_mono_corpus',
'learn_subword', 'apply_subword', 'help']
def cli_main():
parser = argparse.ArgumentParser(
description='Sharable data preprocessing utilities in GluonNLP.',
prog='nlp_process', add_help=False)
parser.add_argument('command', type=str,
choices=SUBCOMMANDS,
metavar='[subcommand]',
help='The subcommand to use. '
'Choices are {}.'.format(SUBCOMMANDS))
args, other_args = parser.parse_known_args()
if args.command == 'clean_tok_para_corpus':
parser = clean_tok_corpus.get_parser.para()
sub_args = parser.parse_args(other_args)
clean_tok_corpus.main_para(sub_args)
elif args.command == 'clean_tok_mono_corpus':
parser = clean_tok_corpus.get_parser.mono()
sub_args = parser.parse_args(other_args)
clean_tok_corpus.main_mono(sub_args)
elif args.command == 'learn_subword':
parser = learn_subword.get_parser()
sub_args = parser.parse_args(other_args)
learn_subword.main(sub_args)
elif args.command == 'apply_subword':
parser = apply_subword.get_parser()
sub_args = parser.parse_args(other_args)
apply_subword.main(sub_args)
elif args.command == 'help':
parser.print_help()
else:
parser.print_help()
if __name__ == '__main__':
cli_main()