42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
import os, sys, re, json
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
base_dir = "resources/knowledge/original/원가계산/건설공사_표준품셈"
|
|
|
|
all_md_files = []
|
|
for root, dirs, files in os.walk(base_dir):
|
|
for f in files:
|
|
if f.endswith('.md') and not f.startswith('_') and '개정사항' not in f and '2026년_건설공사_표준품셈.md' not in f:
|
|
if '01_공통부문\\제8장' in os.path.join(root, f) or '01_공통부문/제8장' in os.path.join(root, f):
|
|
continue
|
|
all_md_files.append(os.path.join(root, f))
|
|
|
|
text_tables = []
|
|
|
|
for fpath in sorted(all_md_files):
|
|
rel_path = os.path.relpath(fpath, base_dir)
|
|
with open(fpath, 'r', encoding='utf-8') as f:
|
|
lines = f.readlines()
|
|
|
|
for idx, line in enumerate(lines):
|
|
line_num = idx + 1
|
|
line_str = line.strip()
|
|
# Non-table line containing table keywords
|
|
if not line_str.startswith('|'):
|
|
if ('구 분' in line_str or '구분' in line_str) and ('단위' in line_str or '단 위' in line_str or '수량' in line_str or '수 량' in line_str):
|
|
# Filter out obvious false positives
|
|
if len(line_str) > 30:
|
|
text_tables.append({
|
|
"file": rel_path,
|
|
"line": line_num,
|
|
"snippet": line_str[:120]
|
|
})
|
|
|
|
print(f"Total non-table lines with embedded tables: {len(text_tables)}")
|
|
for tt in text_tables:
|
|
print(f"{tt['file']} L{tt['line']}: {tt['snippet']}")
|
|
|
|
with open('scratch/text_inline_tables.json', 'w', encoding='utf-8') as f:
|
|
json.dump(text_tables, f, ensure_ascii=False, indent=2)
|