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

Function get_matches

src/licensedcode/match_aho.py:179–190  ·  view source on GitHub ↗

Yield tuples of automaton matches as (match end, match value) from matching the ``tokens`` sequence of token ids starting at the `qbegin` absolute query start position position using the `automaton`.

(tokens, qbegin, automaton)

Source from the content-addressed store, hash-verified

177
178
179def get_matches(tokens, qbegin, automaton):
180 """
181 Yield tuples of automaton matches as (match end, match value) from matching
182 the ``tokens`` sequence of token ids starting at the `qbegin` absolute query
183 start position position using the `automaton`.
184 """
185 # iterate over matched strings: the matched value is (rule id, index start
186 # pos, index end pos)
187 qtokens = tuple(tokens)
188 for qend, matched_value in automaton.iter(qtokens):
189 qend = qbegin + qend + 1
190 yield qend, matched_value
191
192
193def match_fragments(idx, query_run):

Callers 2

get_matched_positionsFunction · 0.70
get_matched_startsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected