-
Notifications
You must be signed in to change notification settings - Fork 29
/
nl2sql.py
executable file
·63 lines (47 loc) · 1.4 KB
/
nl2sql.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Command-line interface for NL2SQL
"""
import os
import plac
from communicate import Communicator
from cli import Download, Setup, Runner
commands = 'download', 'setup', 'run'
@plac.annotations(
path=("Path to download models and jar files (default: ./data)", "option", "p", str),
force=("Force download of all files", "flag", "f", bool)
)
def download(path, force):
"""
Download the Stanford CoreNLP tools and related models.
Install the needed project dependencies.
"""
comm = Communicator()
Download(comm, path or './data').run(force)
@plac.annotations(
force=("Force setup to rerun", "flag", "f", bool)
)
def setup(force):
"""
Setup the project as needed.
"""
comm = Communicator()
if not os.path.isfile('config.cfg'):
comm.error('Make sure to run the download command first.')
Setup(comm).run(force)
@plac.annotations(
debug=("Print out debug statements", "flag", "d", bool)
)
def run(debug):
"""
Start NL2SQL to parse questions
"""
comm = Communicator()
if not os.path.isfile('config.cfg'):
comm.error('Make sure to run the download and setup commands first.')
Runner().start(debug)
def __missing__(name):
print("\n Command %r does not exist."
"\n Use the --help flag for a list of available commands.\n" % name)
main = __import__(__name__)
if __name__ == '__main__':
plac.call(main)