Return a sequence of LicenseMatch by matching the ``qry`` Query against this index. See Index.match() for arguments documentation.
(
self,
qry,
min_score=0,
as_expression=False,
expression_symbols=None,
approximate=True,
unknown_licenses=False,
deadline=sys.maxsize,
_skip_hash_match=False,
**kwargs,
)
| 964 | ) |
| 965 | |
| 966 | def match_query( |
| 967 | self, |
| 968 | qry, |
| 969 | min_score=0, |
| 970 | as_expression=False, |
| 971 | expression_symbols=None, |
| 972 | approximate=True, |
| 973 | unknown_licenses=False, |
| 974 | deadline=sys.maxsize, |
| 975 | _skip_hash_match=False, |
| 976 | **kwargs, |
| 977 | ): |
| 978 | """ |
| 979 | Return a sequence of LicenseMatch by matching the ``qry`` Query against |
| 980 | this index. See Index.match() for arguments documentation. |
| 981 | """ |
| 982 | |
| 983 | whole_query_run = qry.whole_query_run() |
| 984 | if not whole_query_run or not whole_query_run.matchables: |
| 985 | return [] |
| 986 | |
| 987 | if not _skip_hash_match: |
| 988 | matches = match_hash.hash_match(self, whole_query_run) |
| 989 | if matches: |
| 990 | match.set_matched_lines(matches, qry.line_by_pos) |
| 991 | return matches |
| 992 | |
| 993 | get_spdx_id_matches = partial( |
| 994 | self.get_spdx_id_matches, |
| 995 | expression_symbols=expression_symbols, |
| 996 | ) |
| 997 | |
| 998 | if as_expression: |
| 999 | matches = get_spdx_id_matches(qry, from_spdx_id_lines=False) |
| 1000 | match.set_matched_lines(matches, qry.line_by_pos) |
| 1001 | return matches |
| 1002 | |
| 1003 | matches = [] |
| 1004 | |
| 1005 | if USE_AHO_FRAGMENTS: |
| 1006 | approx = self.get_fragments_matches |
| 1007 | else: |
| 1008 | approx = self.get_approximate_matches |
| 1009 | |
| 1010 | matchers = [ |
| 1011 | # matcher, include_low in post-matching remaining matchable check |
| 1012 | Matcher(function=get_spdx_id_matches, include_low=True, name='spdx_lid', continue_matching=True), |
| 1013 | Matcher(function=self.get_exact_matches, include_low=False, name='aho', continue_matching=False), |
| 1014 | ] |
| 1015 | |
| 1016 | if approximate: |
| 1017 | matchers += [Matcher(function=approx, include_low=False, name='seq', continue_matching=False), ] |
| 1018 | |
| 1019 | already_matched_qspans = [] |
| 1020 | for matcher in matchers: |
| 1021 | if TRACE: |
| 1022 | logger_debug() |
| 1023 | logger_debug(f'match_query: matching with matcher: {matcher.name}') |
no test coverage detected