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

Method tokens

src/licensedcode/models.py:2313–2342  ·  view source on GitHub ↗

Return a sequence of token strings for this rule text. SIDE EFFECT: Computed attributes such as "length", "relevance", "is_continuous", "minimum_coverage" and "stopword_by_pos" are recomputed as a side effect.

(self)

Source from the content-addressed store, hash-verified

2311 return self
2312
2313 def tokens(self):
2314 """
2315 Return a sequence of token strings for this rule text.
2316
2317 SIDE EFFECT: Computed attributes such as "length", "relevance",
2318 "is_continuous", "minimum_coverage" and "stopword_by_pos" are
2319 recomputed as a side effect.
2320 """
2321
2322 text = self.text
2323 # We tag this rule as being a bare URL if it starts with a scheme and is
2324 # on one line: this is used to determine a matching approach
2325
2326 if (
2327 text.startswith(('http://', 'https://', 'ftp://'))
2328 and '\n' not in text[:1000]
2329 ):
2330 self.minimum_coverage = 100
2331
2332 toks, stopwords_by_pos = index_tokenizer_with_stopwords(text)
2333 self.length = len(toks)
2334 self.stopwords_by_pos = stopwords_by_pos
2335 self.set_relevance()
2336
2337 # set required phrase spans that must be present for the rule
2338 # to pass through refinement
2339 self.required_phrase_spans = self.build_required_phrase_spans()
2340 self._set_continuous()
2341
2342 return toks
2343
2344 def _set_continuous(self):
2345 """

Calls 4

set_relevanceMethod · 0.95
_set_continuousMethod · 0.95