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

Method tokenize_and_build_runs

src/licensedcode/query.py:527–545  ·  view source on GitHub ↗

Tokenize this query and populate tokens and query_runs at each break point. Only keep known token ids but consider unknown token ids to break a query in runs. `tokens_by_line` is the output of the self.tokens_by_line() method and is an iterator of lines (eg.

(self, tokens_by_line, line_threshold=4)

Source from the content-addressed store, hash-verified

525 logger_debug(f' self.stopwords_by_pos: {self.stopwords_by_pos}')
526
527 def tokenize_and_build_runs(self, tokens_by_line, line_threshold=4):
528 """
529 Tokenize this query and populate tokens and query_runs at each break
530 point. Only keep known token ids but consider unknown token ids to break
531 a query in runs.
532
533 `tokens_by_line` is the output of the self.tokens_by_line() method and
534 is an iterator of lines (eg. lists) of token ids.
535
536 `line_threshold` is the number of empty or junk lines to break a new run.
537 """
538 self._tokenize_and_build_runs(tokens_by_line, line_threshold)
539
540 if TRACE_QR:
541 print()
542 logger_debug('Initial Query runs for query:', self.location)
543 for qr in self.query_runs:
544 print(' ' , repr(qr))
545 print()
546
547 def refine_runs(self):
548 # TODO: move me to the approximate matching loop so that this is done

Callers 2

__init__Method · 0.95

Calls 2

logger_debugFunction · 0.70

Tested by 1