-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch_case.py
More file actions
67 lines (57 loc) · 1.43 KB
/
switch_case.py
File metadata and controls
67 lines (57 loc) · 1.43 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
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/python
""" What does this program do?
input --> what is vim
oputput --> you get three list
1] tech_flag = which tech word it has
2] wh_flag = which wh question does it have
3] ques = get all questions that of technical word
4] set the weightage on basis of wh questions (to be done)
"""
def test(in_que):
# input = raw_input("Enter the sentence: ")
input = in_que
input = input.lower()
input = input.replace('?','') # this is to remove ? from sentence need to add forther
sen = input.split(' ')
# print sen
tech = ['vim','gedit','vlc']
wh = ['what','how','where','when']
tech_flag = []
wh_flag = []
for i in sen:
for j in tech:
if i == j:
tech_flag.append(i)
# print tech_flag
for i in sen:
for j in wh:
if i == j:
wh_flag.append(i)
# print wh_flag
def vim():
fd = open("vim_questions")
questions = fd.readlines()
return questions
def gedit():
fd = open("gedit_questions")
questions = fd.readlines()
return questions
def vlc():
fd =open("vlc_questions")
questions = fd.readlines()
return questions
def default(): # need to write a logic here for default case
print "default value"
mycase = {
'vim': vim,
'gedit':gedit,
'vlc':vlc,
'':default
}
try:
myfunc = mycase[tech_flag[0]] # considering only one tech word in question. For two we need implement
except IndexError:
myfunc = default
ques = myfunc()
print tech_flag[0]
return ques,wh_flag,tech_flag