Beispiel #1
0
 def distanceTest(computedMatches):
     if not computedMatches: return False
     _flatten = lazy.flatten
     for computedMatchPair in lazy.nary_subset(
             list(_flatten(computedMatches)), 2):
         if abs(computedMatchPair[0].position -
                computedMatchPair[1].position) <= distanceConstraint:
             return True
Beispiel #2
0
	def computedMatchSubsets(self,minSubsetSize=1,maxSubsetSize=5):
		"""Return a new ComputedMatch with termInstanceVectors containing all the sub-sets of self.termInstaceVectors
		Sub-sets will contain minSubsetSize to maxSubsetSize members
		If maxSubsetSize is None and minSubsetSize=1 then this will effectively compute the powerset of self
		*The POWERSET can be HUGE, be careful*"""
		powerset = list()
		minSubsetSize = minSubsetSize or 1
		maxSubsetSize = maxSubsetSize or sys.maxint
		if maxSubsetSize < minSubsetSize: maxSubsetSize = minSubsetSize + 1
		for subsetSize in xrange(minSubsetSize,maxSubsetSize + 1):
			try:
				powerset += list(lazy.nary_subset(self.termInstanceVectors,subsetSize))
			except StopIteration:
				break

		return ComputedMatch(self.docId,powerset)
Beispiel #3
0
    def computedMatchSubsets(self, minSubsetSize=1, maxSubsetSize=5):
        """Return a new ComputedMatch with termInstanceVectors containing all the sub-sets of self.termInstaceVectors
		Sub-sets will contain minSubsetSize to maxSubsetSize members
		If maxSubsetSize is None and minSubsetSize=1 then this will effectively compute the powerset of self
		*The POWERSET can be HUGE, be careful*"""
        powerset = list()
        minSubsetSize = minSubsetSize or 1
        maxSubsetSize = maxSubsetSize or sys.maxint
        if maxSubsetSize < minSubsetSize: maxSubsetSize = minSubsetSize + 1
        for subsetSize in xrange(minSubsetSize, maxSubsetSize + 1):
            try:
                powerset += list(
                    lazy.nary_subset(self.termInstanceVectors, subsetSize))
            except StopIteration:
                break

        return ComputedMatch(self.docId, powerset)
Beispiel #4
0
	def distanceTest(computedMatches):
		if not computedMatches: return False
		_flatten = lazy.flatten
		for computedMatchPair in lazy.nary_subset(list(_flatten(computedMatches)),2):
			if abs(computedMatchPair[0].position - computedMatchPair[1].position) <= distanceConstraint:
				return True