Raw Statute Schema (kr2akn.raw-law.v1)

This document fixes the intermediate schema produced by kr2akn before AKN emission. It is deliberately independent of any database or server runtime.

1. Input

  • Endpoint: Korean Law Open Data API (law.go.kr/DRF/lawService.do)
  • Target: eflaw
  • Type: XML
  • Root: <법령 법령키="...">
  • The OC key is read from --oc or LAWGO_OC and is never written to meta.json or the raw snapshot.

A raw snapshot is stored as:

data/raw/eflaw/<law_id>/<YYYYMMDD_HHMMSSZ>/
├── response.xml
└── meta.json      # url (OC removed), fetched_at, bytes, sha256

2. Raw document shape

<법령 법령키="...">
  <기본정보>
    <법령ID>001706</법령ID>
    <법령명_한글>민법</법령명_한글>
    <법종구분 법종구분코드="A0002">법률</법종구분>
    <소관부처 소관부처코드="1270000">법무부</소관부처>
    <공포일자>20260317</공포일자>
    <시행일자>20260317</시행일자>
    <연락부서>
      <부서단위 부서키="...">
        <소관부처명>법무부</소관부처명>
        <부서명>법무심의관실</부서명>
        <부서연락처>02-2110-3164</부서연락처>
      </부서단위>
    </연락부서>
  </기본정보>
  <조문>
    <조문단위>...</조문단위>
  </조문>
  <부칙><부칙단위 부칙키="...">...</부칙단위></부칙>
  <개정문><개정문내용>...</개정문내용></개정문>
  <제개정이유><제개정이유내용>...</제개정이유내용></제개정이유>
  <별표><별표단위 별표키="...">...</별표단위></별표>
</법령>

2.1 조문단위 variants

조문단위 is overloaded. The reader distinguishes by 조문여부 and 조문내용:

Raw shape Meaning Reader output
조문여부=전문, body 제1편 총칙 part heading PART
조문여부=전문, body 제1장 통칙 chapter heading CHAPTER
조문여부=전문, body 제1절 능력 section heading SECTION
조문여부=전문, body 제3관 파양 subsection heading SUBSECTION
조문여부=전문, body 제9절의2 여행계약 branched section heading SECTION with branch
조문여부=전문, body 제1항 협의상 파양 generic heading below a subsection HCONTAINER
조문여부=조문, body 제1조(목적) ... article ARTICLE
조문단위 > 항 > 호 > 목 paragraph/point/indent PARAGRAPH / POINT / INDENT
조문단위 > 항 with empty 항번호/항내용 and 호 children eflaw wrapper artifact 호 promoted to ARTICLE children

The HCONTAINER level is a deliberate escape hatch for raw headings that do not map 1:1 to an AKN hierarchy element. It will map to AKN hcontainer (or level) in the emitter.

3. Intermediate model

RawLaw:

Field Type Notes
schema_version string kr2akn.raw-law.v1
meta LawMeta law-level metadata
units Unit[] nested hierarchy
bylaws Bylaw[] 부칙
annexes Annex[] 별표
amendment_text string? 개정문
amendment_reason string? 제개정이유

LawMeta:

Field Notes
law_id, law_key 법령ID, 법령키
law_name, law_name_hanja, law_name_english, short_name names
law_type, law_type_code 법종구분
ministry, ministry_code 대표 소관부처
departments[] {key, name, ministry, ministry_code, contact} from 연락부서/부서단위
contact_department_raw verbatim 연락부서 text
promulgation_date, promulgation_no ISO date / number
effective_date, effective_end_date, revision_type, language 시행일자 / 시행종료일자(또는 폐지일자) / 제개정구분 / 언어
source_url, raw_path, raw_sha256, fetched_at provenance
extra remaining 기본정보 fields (편장절관, 공동부령정보, ...)

Unit:

Field Notes
level PART, CHAPTER, SECTION, SUBSECTION, HCONTAINER, ARTICLE, PARAGRAPH, POINT, INDENT
path deterministic structural path, e.g. part_1__chp_2__sec_9-2__art_674-2
num display number, e.g. 제4조의2, ①, 5의2., 가.
heading article/heading title
text body text with the leading marker removed
children[] nested units
source_key raw 조문키/항키/호키/목키
effective_date, effective_end_date, revision_type, changed, moved_from, moved_to raw revision metadata (end date from 조문시행종료일자/조문폐지일자 when present)
notes[] 조문참고자료 and trailing <개정 ...> notes
raw verbatim direct-child field map (unless --no-raw)

Bylaw:

Field Notes
key 부칙키
promulgation_date, promulgation_no 부칙공포일자/번호
text verbatim 부칙내용
preamble non-article text before the first 제N조
articles[] article-level units split from 부칙내용
raw field map

Annex:

Field Notes
label 별표, 별표 1, 별표 1의2
number, branch null when raw uses 0000/00
title, title_raw 별표제목 / 별표제목문자열
kind, key, effective_date 별표구분, 별표키, 별표시행일자
text verbatim 별표내용 (may contain box-drawing tables)
file_links, file_names HWP/PDF/image/form links
raw field map

4. Path and label rules

  • Path segments use ASCII and are joined with __.
  • Headings: part_1, chp_2, sec_9-2, subsec_3, hc_hang_1.
  • Articles: art_4, art_4-2 (제4조의2).
  • Paragraphs: para_1, para_2 (circled digits normalized to integers).
  • Points: point_1, point_5-2 (5의2.).
  • Indents: indent_ga, indent_na, indent_ga-2.
  • Parent context is always included: part_1__chp_2__sec_1__art_3__para_2__point_1.
  • The path is deterministic for a given raw document and is the future eId candidate. AKN wId will use the raw *키 values where available.

5. Corpus check (10 major statutes)

Snapshot date: 2026-10-27. Laws:

Law ID Name Type Articles Paragraphs Points Indents Bylaws Annexes
001706 민법 법률 1,193 1,034 206 0 37 0
001702 상법 법률 1,186 1,665 727 7 34 0
001692 형법 법률 402 315 59 0 30 0
001700 민사소송법 법률 523 647 144 3 23 0
001671 형사소송법 법률 617 921 262 0 47 0
001218 행정소송법 법률 46 72 21 0 10 0
009290 민사집행법 법률 313 633 161 0 14 0
001697 부동산등기법 법률 121 184 167 5 15 0
001248 주택임대차보호법 법률 42 103 71 3 25 0
001872 근로기준법 법률 132 225 125 0 30 1

Totals:

조문단위 5,037
ARTICLE 4,575
PARAGRAPH 5,799
POINT 1,943
INDENT 18
PART 29 / CHAPTER 181 / SECTION 184 / SUBSECTION 66 / HCONTAINER 2
bylaws 265
annexes 1
warnings 0

Raw field coverage:

조문가지번호 567
조문참고자료 1,332
조문이동이전/이후 35 each
조문변경여부 Y 35 / N 5,002
항번호 circled 5,799
호번호 numeric 1,927 / numeric branch 16
목번호 korean 18

6. Edge cases locked by this schema

  1. Heading overload — 조문여부=전문 is used for parts, chapters, sections, subsections, branched sections, and generic 제N항 headings. Body-pattern parsing, not 조문번호, decides the level.
  2. Branched headings — 제9절의2 must become sec_9-2, not an article.
  3. Empty 항 wrappers — when 항번호/항내용 are empty and the element only contains 호, the points are promoted to the article. This prevents empty AKN paragraphs.
  4. Point branches — 5의2. becomes point_5-2; the label is not truncated to 5.
  5. Multiple departments — 연락부서/부서단위 is preserved as a list; the top-level 소관부처 is only the representative ministry.
  6. Unnumbered annex — 별표번호=0000, 별표가지번호=00 becomes 별표 (not 별표 0), with 별표제목 preserved.
  7. Annex tables — 별표내용 may be a box-drawing text table. It is kept verbatim in the intermediate model; the table parser will convert it to AKN <table> in the next phase.

7. AKN emission

The emitter is implemented in src/kr2akn/statute/emit.py; see docs/akn-mapping.md for the full contract.

  • PART → part, CHAPTER → chapter, SECTION → section, SUBSECTION → subsection, HCONTAINER → hcontainer.
  • ARTICLE → article, PARAGRAPH → paragraph, POINT → point, INDENT → indent.
  • Bylaw → hcontainer name="부칙" with article-level children.
  • Annex → attachments/attachment/doc/mainBody/table.
  • LawMeta → AKN meta/identification FRBR fields.
  • Inline citations in main-law text → AKN ref elements.