-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
81 lines (71 loc) · 1.73 KB
/
menu.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
import search
import index
import json
import csv
from evalution import *
from tools import *
def displayMenu():
print ""
print ""
print "1: Indexes related tools"
print "2: Search related tools"
print "3: Evaluation related tools"
print "0: Quit"
def displayIndexesMenu():
print ""
print "11: Generate indexes"
print "12: Read indexes from hard drive"
print "13: Write current indexes to hard drive"
print "9: Display main menu"
def displaySearchMenu():
print ""
print "21: Define query"
print "22: Define search mode"
print "23: Perform the search to console"
print "23: Perform the search to CSV"
print "9: Display main menu"
def displayEvaluationMenu():
print ""
print "31: Define mode to evaluate"
print "32: Run evaluation on all the predefined queries"
print "23: Perform the search to console"
print "23: Perform the search to CSV"
print "9: Display main menu"
def makeChoice():
print ""
return input("Make a choice: ")
sourceEval = 'CACM\query.text'
source = 'CACM\cacm.all'
commonwords = 'CACM\common_words'
indexFile = 'ressources\index.json'
iIndexFile = 'ressources\iIndex.json'
cacm = index.Index(source, commonwords)
cacm.generateDico()
displayMenu()
while True:
choice = makeChoice()
if choice == 0:
break
elif choice == 9:
displayMenu()
elif choice == 1:
displayIndexesMenu()
elif choice == 2:
displaySearchMenu()
elif choice ==3:
displayEvaluationMenu()
elif choice == 11:
cacm.generateIndex()
cacm.generateIIndex()
displayMenu()
elif choice ==12:
cacm.loadIndexFromFile(indexFile)
cacm.loadIIndexFromFile(iIndexFile)
displayMenu()
elif choice ==13:
writeToDisk(cacm.index,indexFile)
writeToDisk(cacm.iIndex,iIndexFile)
displayMenu()
else:
displayMenu()