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

Function extend_match

src/licensedcode/seq.py:84–104  ·  view source on GitHub ↗

Extend a match identifier by (besti, bestj, bestsize) with any matching tokens on each end. Return a new Match.

(besti, bestj, bestsize, a, b, alo, ahi, blo, bhi, matchables)

Source from the content-addressed store, hash-verified

82
83
84def extend_match(besti, bestj, bestsize, a, b, alo, ahi, blo, bhi, matchables):
85 """
86 Extend a match identifier by (besti, bestj, bestsize) with any matching
87 tokens on each end. Return a new Match.
88 """
89 if bestsize:
90 while (besti > alo and bestj > blo
91 and a[besti - 1] == b[bestj - 1]
92 and (besti - 1) in matchables):
93
94 besti -= 1
95 bestj -= 1
96 bestsize += 1
97
98 while (besti + bestsize < ahi and bestj + bestsize < bhi
99 and a[besti + bestsize] == b[bestj + bestsize]
100 and (besti + bestsize) in matchables):
101
102 bestsize += 1
103
104 return Match(besti, bestj, bestsize)
105
106
107def match_blocks(a, b, a_start, a_end, b2j, len_good, matchables=frozenset(), *args, **kwargs):

Callers 2

match_fragmentsFunction · 0.90
find_longest_matchFunction · 0.85

Calls 1

MatchFunction · 0.85

Tested by

no test coverage detected