import json
from src.tools import execute_tool
# ROW_TOLERANCE를 늘려서 2줄 헤더를 인식하도록 설정
print("=" * 80)
print("ROW_TOLERANCE를 늘려서 2줄 헤더 인식...")
print("=" * 80)
# row_tolerance를 7.0으로 설정 (헤더 2줄 간격이 6.52)
# col_tolerance를 20.0으로 줄여서 칼럼 구분
result = execute_tool("extract_material_table", {
"row_tolerance": 7.0,
"col_tolerance": 20.0
})
print("\nextract_material_table 실행 결과 (row_tolerance=7.0, col_tolerance=20.0)")
print("=" * 80)
if result.get("status") == "ok":
# NO 칼럼 좌표 추출
categories = result.get("categories", {})
for category_name, category_data in categories.items():
print(f"\n[{category_name}]")
columns = category_data.get("columns", {})
header_y = category_data.get("header_y")
if "NO" in columns:
no_x = columns["NO"]
print(f"\n✓ NO 칼럼 찾음!")
print(f" X좌표: {no_x}")
print(f" Y좌표 (헤더): {header_y}")
else:
print(f"\n✗ NO 칼럼을 찾지 못했습니다.")
print(f"\n모든 칼럼 좌표 ({len(columns)}개):")
for col_name, x_coord in columns.items():
print(f" {col_name}: X={x_coord:.2f}")
# 처음 3개 행만 출력
rows = result.get("rows", [])
print(f"\n총 {len(rows)}개 행 중 처음 3개 항목:")
print("=" * 80)
for i, row in enumerate(rows[:3], 1):
print(f"\n항목 {i}:")
for key, value in row.items():
print(f" {key}: {value}")
else:
print(f"에러 발생: {result.get('message', '알 수 없는 에러')}")
print("\n" + "=" * 80)
print("전체 결과 (JSON):")
print("=" * 80)
print(json.dumps(result, ensure_ascii=False, indent=2))