import json,pathlib,re B=json.load(open('plans/extract-remaining-elements/batch_1.json')) for r in B: p=pathlib.Path(r['output']);s=p.read_text() s=s.replace('### 8.4 증명 곤란','## §8.4 증명책임·추정의 적용 한계').replace('### 12.6 학설','## §12.6 요건 분류에 영향을 주는 견해 차이') s=s.replace('### 10.4 청구취지','## §10.4 청구취지 특정 보충') s=re.sub(r'\((?:검증 문서|검증보고서) 4절(?: 반영)?\)','',s) s=s.replace('; 검증 문서 4절','').replace('검증 문서 4절; 기존 ','원문 반영: ') # Convert review-history lead paragraphs to the substantive qualification only. s=re.sub(r'^UNVERIFIED — R3:.*$', 'UNVERIFIED — 동일성 침해, 주등기의 유효 존속, 피고가 등기의무자·등기명의인이 아닌 경우의 각하/기각 경계에는 미해결 사항이 남는다.',s,flags=re.M) s=re.sub(r'^UNVERIFIED — R2:.*$', 'UNVERIFIED — 주등기 자체의 원인무효에 대한 공방상 성질·증명책임 및 실체관계 부합 항변의 요건 배열에는 유보가 남는다.',s,flags=re.M) s=s.replace('검증 문서 4절에 따라 ','원문은 ').replace('검증 문서 4절에 따라, ','원문은 ') # Drop purely illustrative evidence inventory sentences while retaining all operative legal sentences. out=[] for ln in s.splitlines(): m=re.match(r'^- \*\*증명 실무\*\*\s*[::]\s*(.*)',ln) if m: parts=re.split(r'(?<=다\.)\s+|(?<=증\.)\s+',m[1]);kept=[] for part in parts: pure=bool(re.search(r'^(?:계약서|등기사항증명서|등기부|입금|송금|통장|진단서|의사록|약정서|신고서|어업권원부|급여명세서|청구서|운송장|문자메시지|내용증명|영수증|취업규칙)',part)) operative=bool(re.search(r'경우|단서|요건|추정|전환|한정|효력|권리|의무|책임|다만|기간|기산|항변|원고|피고|갈린|달라|성립|구별|UNVERIFIED|UNKNOWN|QUALIFIED',part)) if pure and not operative and re.search(r'전형|증거|제시|확인|증명|서류|내역|자료',part):continue kept.append(part) if not kept:continue ln='- **추정·입증 적용 설명**: '+' '.join(kept) out.append(ln) s='\n'.join(out)+'\n' # Remove empty template-only headings after extraction. # Keep empty structural headings because they carry route and section identities. s=re.sub(r'\n{3,}','\n\n',s) p.write_text(s)