-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
29 lines (26 loc) · 789 Bytes
/
main.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
# -*- coding:utf-8 -*-
__author__ = 'jrlimingyang@jd.com'
from parse import *
from query import QueryProcessor
import operator
def main():
qp = QueryParser(filename='./data/queries.txt')
cp = CorpusParser(filename='./data/corpus.txt')
qp.parse()
queries = qp.get_queries()
cp.parse()
corpus = cp.get_corpus()
proc = QueryProcessor(queries, corpus)
results = proc.run()
qid = 0
for result in results:
sorted_x = sorted(result.iteritems(), key=operator.itemgetter(1))
sorted_x.reverse()
index = 0
for i in sorted_x[:10]:
tmp = (qid, i[0], index, i[1])
print '{:>1}\tQ0\t{:>4}\t{:>2}\t{:>12}\tL-BM25'.format(*tmp)
index += 1
qid += 1
if __name__ == '__main__':
main()