import sys, os, re, json sys.stdout.reconfigure(encoding='utf-8') base_dir = "resources/knowledge/original/원가계산/건설공사_표준품셈" merged_file = os.path.join(base_dir, "2026년_건설공사_표준품셈.md") with open(merged_file, 'r', encoding='utf-8') as f: merged_text = f.read() # Check key restored tables in merged_text: # 1. 제8장 손료표 11곳: 0230, 3601, 5220, 6532, 6801, 7101, 7120, 7830, 7995, 9020, 9060 loss_codes = ['0230', '3601', '5220', '6532', '6801', '7101', '7120', '7830', '7995', '9020', '9060'] print("=== Checking 11 손료표 in 합본 ===") for code in loss_codes: # search for e.g. "({code})" followed by table pattern = re.compile(rf'\({code}\)[^\n]*\n+(\|[^\n]+\|\n)+', re.DOTALL) m = pattern.search(merged_text) if m: # count rows in table rows = [l for l in m.group(0).split('\n') if l.strip().startswith('|') and not re.match(r'^\|(?:\s*:?-+:?\s*\|)+$', l.strip())] print(f" - ({code}): Restored as table with {len(rows)} rows in 합본") else: # check if it exists as text m2 = re.search(rf'\({code}\)', merged_text) if m2: print(f" ❌ ({code}): Exists as TEXT only (NOT TABLE) in 합본!") else: print(f" ❌ ({code}): Missing in 합본!") # 2. Check 1-2-2 in merged_text print("\n=== Checking 1-2-2 in 합본 ===") if "돌 쌓 기 및 돌 붙 임" in merged_text: # check if it is collapsed or separate rows p_122 = re.compile(r'\|\s*돌\s*쌓\s*기\s*및\s*돌\s*붙\s*임\s*사\s*석') if p_122.search(merged_text): print(" ❌ 1-2-2 is COLLAPSED in 합본!") else: print(" ✅ 1-2-2 is properly expanded in 합본") else: print(" ❓ 1-2-2 not matched") # 3. Check 6-1-1 in merged_text print("\n=== Checking 6-1-1 in 합본 ===") if "6-1-1 레디믹스트콘크리트 타설" in merged_text: print(" ✅ 6-1-1 exists in 합본") else: print(" ❌ 6-1-1 is MISSING in 합본!")