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

Function restore_non_overlapping

src/licensedcode/match.py:1526–1548  ·  view source on GitHub ↗

Return a tuple of (matches, discarded) sequences of LicenseMatch given `matches` and `discarded` sequences of LicenseMatch. Reintegrate as matches these that may have been filtered too agressively.

(matches, discarded)

Source from the content-addressed store, hash-verified

1524
1525
1526def restore_non_overlapping(matches, discarded):
1527 """
1528 Return a tuple of (matches, discarded) sequences of LicenseMatch given
1529 `matches` and `discarded` sequences of LicenseMatch. Reintegrate as matches
1530 these that may have been filtered too agressively.
1531 """
1532 all_matched_qspans = Span().union(*(m.qspan for m in matches))
1533
1534 to_keep = []
1535 to_keep_append = to_keep.append
1536
1537 to_discard = []
1538 to_discard_append = to_discard.append
1539
1540 for disc in merge_matches(discarded):
1541 if not disc.qspan & all_matched_qspans:
1542 # keep previously discarded matches that do not intersect at all
1543 to_keep_append(disc)
1544 disc.discard_reason = DiscardReason.NOT_DISCARDED
1545 else:
1546 to_discard_append(disc)
1547
1548 return to_keep, to_discard
1549
1550
1551def filter_below_rule_minimum_coverage(

Calls 3

SpanClass · 0.90
merge_matchesFunction · 0.85
unionMethod · 0.80