示例#1
0
 def __init__(self, td, n, w):
     self.termDocs = td
     self.norms = n
     self.weight = w
     self.scoreCache = [
         similarity.tf(i) * self.weight
         for i in range(self.SCORE_CACHE_SIZE)
     ]
示例#2
0
文件: term.py 项目: Atom66/tain335
    def score(self, end):
        
        for d, f in self.termDocs.read():
            if d >= end:
                break
            if f < self.SCORE_CACHE_SIZE:
                score = self.scoreCache[f]
            else:
                # cache miss
                score = similarity.tf(f) * self.weight

            # normalize for field
            score *= similarity.normByte(self.norms[d])
            # collect score
            yield (d, score)
        else:
            # close stream
            self.termDocs.close()
            # set to sentinel value
            self.doc = sys.maxint
示例#3
0
    def score(self, end):

        for d, f in self.termDocs.read():
            if d >= end:
                break
            if f < self.SCORE_CACHE_SIZE:
                score = self.scoreCache[f]
            else:
                # cache miss
                score = similarity.tf(f) * self.weight

            # normalize for field
            score *= similarity.normByte(self.norms[d])
            # collect score
            yield (d, score)
        else:
            # close stream
            self.termDocs.close()
            # set to sentinel value
            self.doc = sys.maxint
示例#4
0
文件: term.py 项目: Atom66/tain335
 def __init__(self, td, n, w):
     self.termDocs = td
     self.norms = n
     self.weight = w
     self.scoreCache = [similarity.tf(i) * self.weight for i in range(self.SCORE_CACHE_SIZE)]