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

Function get_undetected_matches

src/licensedcode/detection.py:1614–1661  ·  view source on GitHub ↗

Return a list of LicenseMatch (with a single match) created for an unknown license match with the ``query_string``. Return an empty list if both name and text are empty.

(query_string)

Source from the content-addressed store, hash-verified

1612
1613
1614def get_undetected_matches(query_string):
1615 """
1616 Return a list of LicenseMatch (with a single match) created for an unknown
1617 license match with the ``query_string``.
1618
1619 Return an empty list if both name and text are empty.
1620 """
1621 if not query_string:
1622 return []
1623
1624 query_string = f'license {query_string}'
1625 # FIXME: track lines
1626 expression_str = 'unknown'
1627
1628 idx = get_index()
1629 query = Query(query_string=query_string, idx=idx)
1630
1631 query_run = query.whole_query_run()
1632
1633 match_len = len(query_run)
1634 match_start = query_run.start
1635 matched_tokens = query_run.tokens
1636
1637 qspan = Span(range(match_start, query_run.end + 1))
1638 ispan = Span(range(0, match_len))
1639 len_legalese = idx.len_legalese
1640 hispan = Span(p for p, t in enumerate(matched_tokens) if t < len_legalese)
1641
1642 undetected_rule = UnDetectedRule(
1643 license_expression=expression_str,
1644 text=query_string,
1645 length=match_len,
1646 )
1647
1648 match = LicenseMatch(
1649 rule=undetected_rule,
1650 qspan=qspan,
1651 ispan=ispan,
1652 hispan=hispan,
1653 query_run_start=match_start,
1654 matcher=MATCHER_UNDETECTED,
1655 matcher_order=MATCHER_UNDETECTED_ORDER,
1656 query=query_run.query,
1657 )
1658
1659 matches = [match]
1660 set_matched_lines(matches, query.line_by_pos)
1661 return matches
1662
1663
1664def get_matches_from_detection_mappings(license_detections):

Callers 2

Calls 7

whole_query_runMethod · 0.95
get_indexFunction · 0.90
QueryClass · 0.90
SpanClass · 0.90
UnDetectedRuleClass · 0.90
LicenseMatchClass · 0.90
set_matched_linesFunction · 0.90

Tested by

no test coverage detected