89 lines
3.3 KiB
Python
89 lines
3.3 KiB
Python
import json
|
|
import sys
|
|
import re
|
|
from pathlib import Path
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
# Load basis_missing_2026-01-01.json
|
|
missing_file = Path('resources/data_work_item_master/basis_missing_2026-01-01.json')
|
|
with open(missing_file, 'r', encoding='utf-8') as f:
|
|
missing_data = json.load(f)
|
|
|
|
print("basis_missing keys:", list(missing_data.keys()))
|
|
missing_records = missing_data.get('items', [])
|
|
print(f"Total missing records: {len(missing_records)}")
|
|
|
|
# Load original MD lines
|
|
md_path = Path("resources/knowledge/original/행정규칙/임도 품셈 적용기준 (현 산림사업 표준품셈)/첨부/(산림청고시 제2025-82호) 산림사업 표준품셈.md")
|
|
with open(md_path, "r", encoding="utf-8") as f:
|
|
md_lines = f.readlines()
|
|
|
|
# Load enriched tables
|
|
sys.path.insert(0, '.')
|
|
from scratch.enrich_tables import tables
|
|
|
|
tables_by_id = {t['table_id']: t for t in tables}
|
|
|
|
# Check each of the 88 missing tables
|
|
# Category 1: Dimensionless / Coefficient / Reference / Pure text guide (원문에 밑수 개념 자체가 없음)
|
|
# Category 2: Header / Pre-context contains explicit quantity/unit (원문에 있는데 파서가 못 읽음)
|
|
category_no_basis_in_md = []
|
|
category_has_basis_in_md = []
|
|
|
|
basis_pattern = re.compile(r'\[\s*([0-9\.\,]*)\s*([a-zA-Z㎡㎥㏊ha본개공mkm㎏gtonLℓ대인組]+)\s*당\s*\]')
|
|
basis_pattern2 = re.compile(r'\(단위\s*:\s*([^\)]+)\)')
|
|
|
|
for rec in missing_records:
|
|
tid = rec.get('pum_table_id')
|
|
t = tables_by_id.get(tid)
|
|
if not t:
|
|
continue
|
|
|
|
pre_lines = t.get('pre_context', [])
|
|
header_line = t.get('lines', [''])[0]
|
|
|
|
# Check if pre_lines or headers have basis
|
|
found_basis = None
|
|
for pl in reversed(pre_lines):
|
|
m = basis_pattern.search(pl)
|
|
if m:
|
|
found_basis = pl
|
|
break
|
|
m2 = basis_pattern2.search(pl)
|
|
if m2:
|
|
found_basis = pl
|
|
break
|
|
|
|
# Check table form or characteristics
|
|
pform = rec.get('pum_form')
|
|
|
|
if found_basis:
|
|
category_has_basis_in_md.append({
|
|
'table_id': tid,
|
|
'section': rec.get('section'),
|
|
'pum_form': pform,
|
|
'line': t.get('start_line'),
|
|
'evidence': found_basis
|
|
})
|
|
else:
|
|
category_no_basis_in_md.append({
|
|
'table_id': tid,
|
|
'section': rec.get('section'),
|
|
'pum_form': pform,
|
|
'line': t.get('start_line'),
|
|
'reason': '계수표·할증률표·규격기준표 또는 원문에 단위수량 없음'
|
|
})
|
|
|
|
print(f"\nAnalysis of 88 Missing Basis Tables:")
|
|
print(f"1. 원문에 밑수가 분명히 명시되어 있으나 파서가 아직 못 읽은 것: {len(category_has_basis_in_md)}개")
|
|
print(f"2. 원문 자체에 밑수(단위수량)가 없는 무차원·계수·참고 표: {len(category_no_basis_in_md)}개")
|
|
|
|
print("\n--- [그룹 1: 원문에 있는데 아직 못 읽은 표] 전수 명세 ---")
|
|
for it in category_has_basis_in_md:
|
|
print(f" [{it['table_id']} | line {it['line']}] {it['section']} (form: {it['pum_form']}) -> 증거: {it['evidence']}")
|
|
|
|
print("\n--- [그룹 2: 원문에 밑수 개념이 없는 표] 샘플 15개 ---")
|
|
for it in category_no_basis_in_md[:15]:
|
|
print(f" [{it['table_id']} | line {it['line']}] {it['section']} (form: {it['pum_form']}) -> {it['reason']}")
|