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

Function break_long_lines

src/licensedcode/query.py:710–717  ·  view source on GitHub ↗

Given an iterable of lines (each being a list of token ids), break lines that contain more than threshold in chunks. Return an iterable of lines.

(lines, threshold=MAX_TOKEN_PER_LINE)

Source from the content-addressed store, hash-verified

708
709
710def break_long_lines(lines, threshold=MAX_TOKEN_PER_LINE):
711 """
712 Given an iterable of lines (each being a list of token ids), break lines
713 that contain more than threshold in chunks. Return an iterable of lines.
714 """
715 for line in lines:
716 for i in range(0, len(line), threshold):
717 yield line[i:i + threshold]
718
719
720class QueryRun(object):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected