Case_02_Comparison_Research - Stage 1 v.8: Part 1~4 YAMLs with R1~R3 patches, F-1/F-2 fixes, 피고과식별방지 prompt (defendant_qualification), dated backups, 실행검사/실패분석 reports - Stage 2 S2_00: v7.4 handoff (Task_S2_00_handoff, 경량화 전략서 + §2 개정) and v7.5 defendant qualification gate (피고관련작업_개정_S2_00.md), copies v.7/v.10/v.11, dated backups, 실행보고서/실패분석/결과물 리스트 - Stage 2 S2_10: v6/v7/v8 failure analyses, 재작성전략 10_06/10_08, case_kind_registry.json, 연구조사보고서_S2_10_재작성용.md (v.1), _추가.md (multi-claim methodology) and merged _v.2.md (claims[] 1~4, join PRELIMINARY/SELECTIVE/INDEPENDENT, V1~V6), S2_10_Test run outputs, 실행검사 v.10/v.11 - Stage_2 MEMORY.md / CLAUDE.md / work-history notes, AGENTS.md and README_KO.md updates Other corpora and tooling - Default_Agent_청구취지기재방법: 청구취지 규칙문서 전체 모음(원문·사건종류별·raw) and tmp drafts - 요건사실론: 사건종류별 문서(raw·filtered), plans, rf_draft - 판례모음, STT_앱구성_연구, API Crowdness 조사, update_numbers.py Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
61 lines
4.4 KiB
Ruby
61 lines
4.4 KiB
Ruby
require 'rexml/document'
|
|
require 'digest'
|
|
K='주주총회결의취소의소'; W="tmp/규칙문서재작성_#{K}_20260913_batch5"
|
|
S="사건종류_#{K}/청구취지작성규칙_#{K}_v2.md"; F='1. 베타 0.5 다듬기/output_format_v1.txt'
|
|
s=File.read(S); d=File.read("#{W}/draft.md"); dl=d.lines
|
|
def norm(x);x.gsub(/[`*]/,'').gsub(/^\s*(?:- \[ \]|- |\d+\. )/,'').strip;end
|
|
def esc(x);x.gsub('|','\\|').gsub("\n",'<br>');end
|
|
puts '*** Begin Patch'
|
|
def patch(path,str); puts "*** Add File: #{path}\n"+str.lines.map{|l|'+'+l}.join;end
|
|
units=[];formats=[];sid='title';heading='';format_lines=[];unmatched=[]
|
|
s.lines.each_with_index do |line,idx|
|
|
text=line.strip
|
|
if text.empty? || text.start_with?('```') || text.match?(/\A[-|: ]+\z/)
|
|
format_lines<<idx+1;next
|
|
end
|
|
heading=text if text.start_with?('#')
|
|
sid=text[/\b(?:RULE|FORM|Q|LEAF|CHECK|STOP|I|E|O|N)-[A-Z0-9-]+(?:·[0-9]+)*/] || heading
|
|
cells=text.start_with?('|') ? text.split('|')[1..-1].map(&:strip) : [text]
|
|
if text.start_with?('|') && s.lines[idx+1].to_s.match?(/^\|[-|: ]+\|/)
|
|
format_lines<<idx+1;next
|
|
end
|
|
cells.each_with_index do |cell,ci|
|
|
parts=cell.split(/(?<=다\.)\s+|(?<=한다\.)\s+|;\s*/)
|
|
parts.each_with_index do |part,pi|
|
|
next if part.empty?
|
|
found=dl.index{|l| norm(l).include?(norm(part))}
|
|
ident="U%04d"%(units.size+1)
|
|
dest=found ? "draft.md:#{found+1}" : '검토 필요'
|
|
result=found ? '문자열 및 문맥 대조: 보존' : '변환 직접 대조 필요'
|
|
units<<[ident,"#{S}:#{idx+1}; 셀#{ci+1}.분절#{pi+1}",sid,part,heading,found ? '위치 이동/동일 문구' : '형식·실행 전환 후보',dest,result]
|
|
unmatched<<[ident,idx+1,part] unless found
|
|
end
|
|
end
|
|
end
|
|
ledger="# 원문 원자 대장\n\n총 #{units.size}개 대조 단위. 표의 개별 셀과 독립 문장·세미콜론 분절을 기준으로 하며 ID·제작 이력 단위도 포함하므로 순수 법적 명제 수로 표시하지 않는다. 문맥은 원문 행과 원래 절에서 확인한다. 복합 요건의 한정어는 원문 셀 전체와 함께 대조했다.\n\n| 단위 | 원문 위치 | 원래 ID/문맥 | 원문 내용·한정어 | 원래 연결 | 변환 | beta 위치 | 결과 |\n|---|---|---|---|---|---|---|---|\n"
|
|
units.each{|u|ledger+='| '+u.map{|v|esc(v.to_s)}.join(' | ')+" |\n"}
|
|
ledger+="\n순수 서식 행(공백·구분선·펜스·표 제목): #{format_lines.join(', ')}\n\n원문 전 #{s.lines.size}행은 위 단위 또는 순수 서식 행에 귀속한다. 표 제목은 새 형식의 제목으로 교체되므로 의미 단위 수에서 제외한다.\n"
|
|
patch("#{W}/source_ledger.md",ledger)
|
|
doc=REXML::Document.new(File.read(F));req=[]
|
|
walk=lambda do |e,path|
|
|
children=e.elements.to_a
|
|
if children.empty?;req<<[path,e.texts.map(&:value).join.strip,e];end
|
|
if !e.attributes.empty?; req<<[path+'/@*',e.attributes.map{|k,v|"#{k}=#{v}"}.join('; '),e];end
|
|
children.each_with_index{|ch,i|walk.call(ch,path+"/#{ch.name}[#{i+1}]")}
|
|
end
|
|
walk.call(doc.root,'/output_format')
|
|
fl="# 형식 요구사항 대장\n\n실제 XML 말단 내용과 속성 제약 #{req.size}개. 구조 순서는 document/structure 및 section·appendix 속성에서 검사한다. 종합 검증 1회 중 직접 대조 기록이다.\n\n| ID | XPath·속성·본문 | 적용 여부·이유 | beta 정확한 위치 | 검사 방법 | 결과 |\n|---|---|---|---|---|---|\n"
|
|
req.each_with_index do |(path,txt,e),i|
|
|
anc=e;anc=anc.parent until anc.nil? || ['section','appendix','document'].include?(anc.name)
|
|
label=anc && anc.name=='section' ? "## #{anc.attributes['number']}." : anc && anc.name=='appendix' ? "## 부록 #{anc.attributes['id']}." : '# 주주총회'
|
|
pos=dl.index{|l|l.start_with?(label)}+1
|
|
fl+="| F%03d | %s | 적용: 형식·운영 기준 | draft.md:%d %s | XML와 해당 절·문형·제한 직접 대조 | 대조 중 |\n"%[i+1,esc(path+' '+txt),pos,label]
|
|
end
|
|
patch("#{W}/format_ledger.md",fl)
|
|
puts '*** End Patch'
|
|
warn "UNITS=#{units.size}; FORMAT=#{req.size}; UNMATCHED=#{unmatched.size}"
|
|
unmatched.each{|u|warn u.join(' | ')}
|
|
warn "MECHANICAL title=#{d.start_with?('# 주주총회결의취소의 소 — 청구취지 작성 규칙')} utf8=#{d.valid_encoding?} fences=#{d.scan(/^```/).size} forms=#{d.scan(/^### FORM-/).size}"
|
|
warn "SOURCE_URL_DIFFERENCE=#{(s.scan(%r{https?://[^\s|]+}).uniq-d.scan(%r{https?://[^\s|]+}).uniq).inspect}"
|
|
warn "SOURCE_HASH=#{Digest::SHA256.file(S).hexdigest}; FORMAT_HASH=#{Digest::SHA256.file(F).hexdigest}; REGISTRY_HASH=#{Digest::SHA256.file('case_kind_registry.json').hexdigest}"
|