forked from aadijain/graham-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresults.py
More file actions
26 lines (24 loc) · 758 Bytes
/
results.py
File metadata and controls
26 lines (24 loc) · 758 Bytes
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
import index_builder as ib;
import os
#prints results on screeen
def print_results(result):
cat = {}
for line in open('corpora/reuters/cats.txt','r'):
fst, _, lst = line.partition(' ')
cat[fst] = lst[:-1]
print("Number of results: %d\n" % (len(result)))
for index, (file, score, _) in enumerate(result):
print("RANK %d" % (index+1))
print("FileName:\t%s" % file)
print("Score:\t\t%s" % score)
print("Category(s):\t%s" % cat[file])
print("File Preview:")
f = open("corpora/reuters/"+file,'r')
f.seek(0)
print("%s..." % f.read(200))
print
#opens specified file in gedit
def fileopen(results, index):
if index <=0 or index>min(len(results),20): return
os.system("gedit corpora/reuters/" + results[index-1][0])
return