import os, sys, re, json sys.stdout.reconfigure(encoding='utf-8') ch13_path = "resources/knowledge/original/원가계산/건설공사_표준품셈/04_기계설비부문/제13장_플랜트설비공사.md" with open(ch13_path, 'r', encoding='utf-8') as f: lines = f.readlines() print(f"Total lines in 제13장: {len(lines)}") collapsed_rows = [] for idx, line in enumerate(lines): line_str = line.strip() if line_str.startswith('|') and line_str.endswith('|'): cells = [c.strip() for c in line_str.split('|')[1:-1]] # Find if any cell has >= 10 space-separated tokens that look like numbers or specifications for c_idx, c in enumerate(cells): tokens = c.split() if len(tokens) >= 8 and any(tok[0].isdigit() for tok in tokens): collapsed_rows.append({ "line": idx + 1, "col_idx": c_idx, "token_count": len(tokens), "first_cell": cells[0][:30], "cell_snippet": c[:100], "tokens": tokens }) break print(f"Found {len(collapsed_rows)} collapsed multi-token rows in 제13장") for r in collapsed_rows: print(f"L{r['line']} (tokens: {r['token_count']}) [{r['first_cell']}]: {r['cell_snippet'][:80]}") with open('scratch/ch13_collapsed_rows.json', 'w', encoding='utf-8') as f: json.dump(collapsed_rows, f, ensure_ascii=False, indent=2)