MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / overlap

Method overlap

src/licensedcode/spans.py:312–330  ·  view source on GitHub ↗

Return the count of overlapping items between this span and other span. For example: >>> Span([1, 2]).overlap(Span([5, 6])) 0 >>> Span([5, 6]).overlap(Span([5, 6])) 2 >>> Span([4, 5, 6, 7]).overlap(Span([5, 6])) 2 >>> Span([4,

(self, other)

Source from the content-addressed store, hash-verified

310 return len(self) / self.magnitude()
311
312 def overlap(self, other):
313 """
314 Return the count of overlapping items between this span and other span.
315
316 For example:
317 >>> Span([1, 2]).overlap(Span([5, 6]))
318 0
319 >>> Span([5, 6]).overlap(Span([5, 6]))
320 2
321 >>> Span([4, 5, 6, 7]).overlap(Span([5, 6]))
322 2
323 >>> Span([4, 5, 6]).overlap(Span([5, 6, 7]))
324 2
325 >>> Span([4, 5, 6]).overlap(Span([6]))
326 1
327 >>> Span([4, 5]).overlap(Span([6, 7]))
328 0
329 """
330 return len(self & other)
331
332 def resemblance(self, other):
333 """

Callers 4

resemblanceMethod · 0.95
containmentMethod · 0.95
distance_toMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected