Example #1
0
 def _f_cover(self, bInd):
     vector_o = self.multiDocs.meanVector
     vector_os = self.multiDocs.getMeanVectorOfSolution(bInd)
     
     cover = helper.cosin(vector_o, vector_os)
     
     t = 0
     for i in xrange(self.multiDocs.numOfSentences):
         if bInd[i] == 1:
             t += helper.cosin(vector_o, self.multiDocs.getSentenceVector(i))
     
     return cover * t
 def _f_cover(self, bInd):
     vector_o = self.multiDocs.meanVector
     vector_os = self.multiDocs.getMeanVectorOfSolution(bInd)
     
     cover = helper.cosin(vector_o, vector_os)
     
     t = 0
     for i in xrange(self.multiDocs.numOfSentences):
         if bInd[i] == 1:
             t += helper.cosin(vector_o, self.multiDocs.getSentenceVector(i))
     
     return cover * t
Example #3
0
 def _f_diver(self, bInd):
     f_diver = 0.0
     for i in xrange(self.multiDocs.numOfSentences-1):
         vector_i = self.multiDocs.getSentenceVector(i)
         for j in xrange(i+1, self.multiDocs.numOfSentences):
             if bInd[i] == 1 and bInd[j] == 1:
                 vector_j = self.multiDocs.getSentenceVector(j)
                 f_diver += helper.cosin(vector_i, vector_j)
     return f_diver
 def _f_diver(self, bInd):
     f_diver = 0.0
     for i in xrange(self.multiDocs.numOfSentences-1):
         vector_i = self.multiDocs.getSentenceVector(i)
         for j in xrange(i+1, self.multiDocs.numOfSentences):
             if bInd[i] == 1 and bInd[j] == 1:
                 vector_j = self.multiDocs.getSentenceVector(j)
                 f_diver += helper.cosin(vector_i, vector_j)
     return f_diver
    def _calCosinMatrix(self):
        '''
        calculate cosin similarity matrix between sentences
        '''
        self.cosinMatrix = [[0]*self.numOfSentences for _ in xrange(self.numOfSentences)]
        
        for i in xrange(self.numOfSentences-1):
            vector_i = self.tfisfVectors[i]
            for j in xrange(i+1, self.numOfSentences):
                vector_j = self.tfisfVectors[j]

                # calculate cosin
                self.cosinMatrix[i][j] = self.cosinMatrix[j][i] = helper.cosin(vector_i, vector_j)
Example #6
0
    def _calCosinMatrix(self):
        '''
        calculate cosin similarity matrix between sentences
        '''
        self.cosinMatrix = [[0] * self.numOfSentences
                            for _ in xrange(self.numOfSentences)]

        for i in xrange(self.numOfSentences - 1):
            vector_i = self.tfisfVectors[i]
            for j in xrange(i + 1, self.numOfSentences):
                vector_j = self.tfisfVectors[j]

                # calculate cosin
                self.cosinMatrix[i][j] = self.cosinMatrix[j][i] = helper.cosin(
                    vector_i, vector_j)