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)
| 708 | |
| 709 | |
| 710 | def 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 | |
| 720 | class QueryRun(object): |
no outgoing calls
no test coverage detected