-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun.py
More file actions
61 lines (52 loc) · 1.58 KB
/
Copy pathRun.py
File metadata and controls
61 lines (52 loc) · 1.58 KB
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
import os
import sys
from ADBProjectPart1 import Infobox
from ADBProjectPart2 import QuestionAnswering
#python Run.py -key XXXXXX -q Who created Microsoft? -t question
key = ''
filePath = ''
query = ''
type = ''
#print(len(sys.argv))
if len(sys.argv) > 0:
query = ""
j=0
for i in xrange(1,len(sys.argv)):
if sys.argv[i] == "-key":
key = sys.argv[i+1]
elif sys.argv[i] == "-t":
type = sys.argv[i+1]
elif sys.argv[i] == "-f":
filePath = sys.argv[i+1]
elif sys.argv[i] == "-q":
j=i
next = sys.argv[j+1]
while '-' not in next:
query = query + next + " "
if j < len(sys.argv):
j = j + 1
next = sys.argv[j+1]
else:
continue
if len(sys.argv) > 3:
if filePath!="" and query =="":
with open(filePath) as queryFile:
for q in queryFile:
if type.lower()=="question":
QuestionAnswering(key,q)
else:
Infobox(key, q)
elif filePath=="" and query !="":
if type.lower()=="question":
QuestionAnswering(key,query)
else:
Infobox(key, query)
else:
query = raw_input("Please enter the query:")
while True:
q = query.strip().split(' ')
if len(q)>2 and q[0].lower() == 'who' and q[1].lower() == 'created':
QuestionAnswering(key,query)
else:
Infobox(key, query)
query = raw_input("Please enter the query:")