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

Function matched_rule_tokens_str

src/licensedcode/tracing.py:55–67  ·  view source on GitHub ↗

Return an iterable of matched rule token strings given a match. Punctuation is removed, spaces are normalized (new line is replaced by a space), case is not preserved.

(match)

Source from the content-addressed store, hash-verified

53
54
55def matched_rule_tokens_str(match):
56 """
57 Return an iterable of matched rule token strings given a match.
58
59 Punctuation is removed, spaces are normalized (new line is replaced by a
60 space), case is not preserved.
61 """
62 for pos, token in enumerate(match.rule.tokens()):
63 if match.ispan.start <= pos <= match.ispan.end:
64 if pos in match.ispan:
65 yield token
66 else:
67 yield '<{}>'.format(token)

Callers 1

get_textsFunction · 0.85

Calls 2

tokensMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected