-
Notifications
You must be signed in to change notification settings - Fork 0
/
Postings.py
45 lines (31 loc) · 1.04 KB
/
Postings.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
'''
Posting store term and its position in each document
<term, docId, docId>
'''
class Postings:
def __init__(self, documentId:int):
self.__documentId = documentId
self.__frequency = 0
self.__positions = []
def setTermFrequency(self,freq:int):
self.__frequency = freq
def getDocumentId(self):
return self.__documentId
# <PositionalPosting2: <docId, [pos1, pos2...]>, <docId, [pos1, pos2...]>...>
class PositionalPostings:
def __init__(self, documentId:int):
self.__documentId = documentId
self.__frequency = 0
self.__positions = []
def setTermFrequency(self,freq:int):
self.__frequency = freq
def getPositions(self):
return self.__positions
def getDocumentId(self):
return self.__documentId
def setPositions(self, positions:[]):
self.__positions = positions
def insertIndex(self,ind: int):
self.__positions.append(ind)
def resetPositions(self):
self.__positions = []