MCPcopy Index your code
hub / github.com/clips/pattern / Weight

Class Weight

pattern/metrics.py:353–368  ·  view source on GitHub ↗

A float with a magic "assessments" property, which is the set of all n-grams contributing to the weight.

Source from the content-addressed store, hash-verified

351 return [tuple(s[i:i+n]) for i in range(len(s)-n+1)]
352
353class Weight(float):
354 """ A float with a magic "assessments" property,
355 which is the set of all n-grams contributing to the weight.
356 """
357 def __new__(self, value=0.0, assessments=[]):
358 return float.__new__(self, value)
359 def __init__(self, value=0.0, assessments=[]):
360 self.assessments = set(assessments)
361 def __iadd__(self, value):
362 return Weight(self + value, self.assessments)
363 def __isub__(self, value):
364 return Weight(self - value, self.assessments)
365 def __imul__(self, value):
366 return Weight(self * value, self.assessments)
367 def __idiv__(self, value):
368 return Weight(self / value, self.assessments)
369
370def intertextuality(texts=[], n=5, continuous=False, weight=lambda ngram: 1):
371 """ Returns a dictionary of (i, j) => float.

Callers 5

__iadd__Method · 0.85
__isub__Method · 0.85
__imul__Method · 0.85
__idiv__Method · 0.85
intertextualityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…