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

Class LicenseMatch

src/licensedcode/match.py:152–855  ·  view source on GitHub ↗

License detection match to a rule with matched query positions and lines and matched index positions. Also computes a score for a match. At a high level, a match behaves a little like a Span and has several similar methods taking into account both the query and index-side Spans.

Source from the content-addressed store, hash-verified

150
151@attr.s(slots=True, eq=False, order=False, repr=False)
152class LicenseMatch(object):
153 """
154 License detection match to a rule with matched query positions and lines and
155 matched index positions. Also computes a score for a match. At a high level,
156 a match behaves a little like a Span and has several similar methods taking
157 into account both the query and index-side Spans.
158
159 Note that the relationship between the query-side qspan Span and the index-
160 side ispan Span is such that:
161
162 - they always have the exact same number of items but when sorted each
163 value at a given index may be different
164 - the nth position when sorted by position is such that their token
165 value is equal for this position.
166
167 These properties mean that the qspan and ispan can be safely zipped with
168 zip(). Also and as a convention throughout, we always use qspan first then
169 ispan: in general we put query-related variables on the left hand side and
170 index-related variables on the right hand side.
171 """
172
173 rule = attr.ib(
174 metadata=dict(
175 help='matched Rule object'
176 )
177 )
178
179 qspan = attr.ib(
180 metadata=dict(
181 help='query text matched Span, start at zero which is the absolute '
182 'query start (not the query_run start)'
183 )
184 )
185
186 ispan = attr.ib(
187 metadata=dict(
188 help='rule text matched Span, start at zero which is the rule start.'
189 )
190 )
191
192 hispan = attr.ib(
193 default=attr.Factory(Span),
194 metadata=dict(
195 help='rule text matched Span for high tokens, start at zero which '
196 'is the rule start. Always a subset of ispan.'
197 )
198 )
199
200 query_run_start = attr.ib(
201 default=0,
202 metadata=dict(
203 help='Starting position of the QueryRun where this match '
204 'was found.'
205 )
206 )
207
208 matcher = attr.ib(
209 default='',

Callers 15

spdx_id_matchFunction · 0.90
get_undetected_matchesFunction · 0.90
exact_matchFunction · 0.90
match_fragmentsFunction · 0.90
hash_matchFunction · 0.90
match_unknownsFunction · 0.90
match_sequenceFunction · 0.90

Calls

no outgoing calls