-
Notifications
You must be signed in to change notification settings - Fork 4
/
relevance_judgement.py
41 lines (30 loc) · 1.04 KB
/
relevance_judgement.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
__author__ = 'Matias'
from search import ElasticSearchEngine
def judge(eval_file='findzebra.tsv'):
search = ElasticSearchEngine()
with open('evaluation/data/%s' % (eval_file,), 'r') as infile:
records = infile.read().split("\n")
finished = [1]
for record in records:
parts = record.split("\t")
query_id = int(parts[0])
if query_id in finished:
continue
query = parts[1]
target = parts[2]
print query
ids = []
hits = search.query(query, top_n=100)
count = 0
for hit in hits:
count += 1
title = hit['description']
pmcid = hit['id']
print "TARGET:", target
print ""
print count, "TITLE:", pmcid, title
if raw_input("Y/N?").lower() == "y":
ids.append(pmcid)
print "ID:", query_id, "---", ",".join(ids)
if __name__ == "__main__":
judge()