Files
Aislo/resources/tester/scratch/check_cut_real_rules.py
T

64 lines
2.2 KiB
Python

import json
import sys
import re
from pathlib import Path
sys.stdout.reconfigure(encoding='utf-8')
sys.path.insert(0, '.')
from scratch.enrich_tables import tables
with open('resources/data_work_item_master/work_item_master_2026-01-01.json', 'r', encoding='utf-8') as f:
master = json.load(f)
master_tables = {}
for wi in master['work_items']:
for t in wi.get('tables', []):
tid = t.get('pum_table_id')
if tid:
master_tables[tid] = t
# We want to know: Did the trimming cut away REAL pricing coefficients/conditions?
# Keywords that indicate actual pricing rules:
rule_keywords = ['%', '가산', '할증', '공제', '손료', '손율', '감한다', '할인', '포함한다', '별도', '규격', '작업량']
cut_real_rules = []
for t in tables:
tid = t['table_id']
mt = master_tables.get(tid)
if not mt:
continue
md_notes = t.get('notes', [])
master_notes = mt.get('notes', [])
# Check lines in md_notes that are NOT in master_notes
for line in md_notes:
line_clean = line.strip()
if not line_clean:
continue
# check if line_clean is present in master_notes
if not any(line_clean in mn for mn in master_notes):
# Is this line a section title like "- 3. ..." or "- 라. ..."?
# Check if it looks like a section heading
is_heading = bool(re.match(r'^[-*•]?\s*(?:[0-9]+[\.\)]|[가-힣][\.\)]|[A-Z][\.\)])\s*[^:%~]+$', line_clean))
is_example = '예시' in line_clean or line_clean.startswith('>')
# Check if it has real pricing rules
has_rule = any(kw in line_clean for kw in rule_keywords)
if has_rule and not is_example and not is_heading:
cut_real_rules.append({
'table_id': tid,
'chapter': t['chapter'],
'section': t['section'],
'line': t['start_line'],
'lost_rule': line_clean
})
print(f"Total potential REAL RULES cut away: {len(cut_real_rules)}")
for cr in cut_real_rules:
print(f"[{cr['table_id']} | line {cr['line']}] {cr['section']}")
print(f" CUT: {cr['lost_rule']}")