MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / split_into_table_blocks

Function split_into_table_blocks

scripts/postprocess_fulltext.py:33–55  ·  view source on GitHub ↗

Split lines into alternating non-table and table blocks. Returns list of ('text'|'table', [lines]) tuples.

(lines: list[str])

Source from the content-addressed store, hash-verified

31
32
33def split_into_table_blocks(lines: list[str]) -> list[tuple[str, list[str]]]:
34 """
35 Split lines into alternating non-table and table blocks.
36 Returns list of ('text'|'table', [lines]) tuples.
37 """
38 blocks = []
39 current_type = None
40 current = []
41
42 for line in lines:
43 in_table = line.startswith('|')
44 block_type = 'table' if in_table else 'text'
45 if block_type != current_type:
46 if current:
47 blocks.append((current_type, current))
48 current_type = block_type
49 current = [line]
50 else:
51 current.append(line)
52
53 if current:
54 blocks.append((current_type, current))
55 return blocks
56
57
58def is_toc_table(table_lines: list[str]) -> bool:

Callers 2

remove_toc_tablesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected