Return a filtered list of kept LicenseMatch matches and a list of weak matches given a `matches` list of LicenseMatch by considering shorter sequence matches with a low coverage or match to unknown licenses. These are set aside before "unknown license" matching.
(matches)
| 1738 | |
| 1739 | |
| 1740 | def split_weak_matches(matches): |
| 1741 | """ |
| 1742 | Return a filtered list of kept LicenseMatch matches and a list of weak |
| 1743 | matches given a `matches` list of LicenseMatch by considering shorter |
| 1744 | sequence matches with a low coverage or match to unknown licenses. These are |
| 1745 | set aside before "unknown license" matching. |
| 1746 | """ |
| 1747 | from licensedcode.match_seq import MATCH_SEQ |
| 1748 | |
| 1749 | kept = [] |
| 1750 | kept_append = kept.append |
| 1751 | discarded = [] |
| 1752 | discarded_append = discarded.append |
| 1753 | |
| 1754 | for match in matches: |
| 1755 | # always keep exact matches |
| 1756 | if (match.matcher == MATCH_SEQ |
| 1757 | and match.len() <= SMALL_RULE |
| 1758 | and match.coverage() <= 25 |
| 1759 | ) or match.rule.has_unknown: |
| 1760 | |
| 1761 | discarded_append(match) |
| 1762 | else: |
| 1763 | kept_append(match) |
| 1764 | |
| 1765 | return kept, discarded |
| 1766 | |
| 1767 | |
| 1768 | def filter_spurious_matches( |