-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcranqry.py
40 lines (34 loc) · 847 Bytes
/
cranqry.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
'''
handling the specific input format of the query.text for the Cranfield data
'''
class CranQry:
def __init__(self, qid, text):
self.qid = qid
self.text = text
def loadCranQry(qfile):
queries = {}
f = open(qfile)
text = ''
qid = ''
for line in f:
if '.I' in line:
if qid !='':
queries[qid] = CranQry(qid, text)
#print ('qid:', qid, text)
qid = line.strip().split()[1]
text = ''
elif '.W' in line:
None
else:
text += line
queries[qid] = CranQry(qid, text)
return queries
def test():
'''testing'''
print("done")
'''qrys = loadCranQry('query.text')
for q in qrys:
print (q, qrys[q].text)
print (len(qrys))'''
if __name__ == '__main__':
test()