Return a containment coefficient as a float between 0 and 1. This is an indication of how much of the other span is contained in this span. - 1 means the other span is entirely contained in this span. - 0 means that the other span is not contained at all this
(self, other)
| 342 | return resemblance |
| 343 | |
| 344 | def containment(self, other): |
| 345 | """ |
| 346 | Return a containment coefficient as a float between 0 and 1. This is an |
| 347 | indication of how much of the other span is contained in this span. |
| 348 | - 1 means the other span is entirely contained in this span. |
| 349 | - 0 means that the other span is not contained at all this span. |
| 350 | """ |
| 351 | if self._set.isdisjoint(other._set): |
| 352 | return 0 |
| 353 | if self._set == other._set: |
| 354 | return 1 |
| 355 | containment = self.overlap(other) / len(other) |
| 356 | return containment |
| 357 | |
| 358 | def surround(self, other): |
| 359 | """ |