-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_querie_B.py
69 lines (53 loc) · 2.25 KB
/
load_querie_B.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
'''
------------------------------------------------------------
Created on Nov 2015 by
Name = Gerardo Roa Dabike
University ID = acp15gr
Registration Number = 150105918
------------------------------------------------------------
'''
from nested_dictionary import NestedDict
class LoadQuerie_B(object):
'''
This Class load the queries and process Term Weigth by Binary
'''
def __init__(self, querieDict,index):
'''
Constructor
'''
self.__indexDict = index
#self.__querieFile = querieFile
self.__querieDict = querieDict
self.__resultDict = self.__retrievalBinary()
def __retrievalBinary(self):
resultDict = NestedDict()
for querie in self.__querieDict:
for word in self.__querieDict[querie]:
if word in self.__indexDict:
for doc in self.__indexDict[word]:
if querie in resultDict:
if doc in resultDict[querie]:
resultDict[querie][doc] += 1
else:
resultDict[querie][doc]=1
else:
resultDict[querie][doc]=1
return resultDict
def getResultDict(self):
return self.__resultDict
#def __createQuerieDict(self):
# print 'Loading Queries...'
# documents = ReadDocuments(self.__querieFile)
# queries = NestedDict()
# for doc in documents:
# docid = doc.docid
# for line in doc.lines:
# token = Tokenizator(line,self.__tok).toToken()
# for tok in token:
# word = Stemmator(tok,self.__stem).toStem()
# if word not in self.__stoplist and word not in string.punctuation:
# if word not in queries[docid]:
# queries[docid][word]=0
# queries[docid][word]+=1
# print 'Queries loaded...'
# return queries