Skip to main content

Japanese Law Parser

PyPI - Version GitHub Workflow Status (with event)

法令標準 XML スキーマに準拠する XML ファイルを解析し、 pydantic のモデルに変換するライブラリです。

e-Gov法令検索で公開されている、日本国の法令 XML(憲法・法律・政令・勅令・府令・省令・規則)をパースし、解析結果を Python から利用することができます。

内部的に pydantic-xml を利用して XML をパースしています。

Installation

pip

pip install ja-law-parser

poetry

poetry add ja-law-parser

Usage

from ja_law_parser.model import Article, Chapter, Law, Paragraph
from ja_law_parser.parser import LawParser

parser = LawParser()

law: Law = parser.parse(path="321CONSTITUTION_19470503_000000000000000.xml")
print(law.law_body.law_title.text)
# => 日本国憲法

chapter3: Chapter = law.law_body.main_provision.chapters[2]
print(chapter3.chapter_title.text)
# => 三章 国民の権利及び義務

article11: Article = chapter3.articles[1]
print(article11.article_title.text)
# => 第十一条

paragraph11: Paragraph = article11.paragraphs[0]
print(paragraph11.paragraph_sentence.sentences[0].text)
# => 国民は、すべての基本的人権の享有を妨げられない。
print(paragraph11.paragraph_sentence.sentences[1].text)
# => この憲法が国民に保障する基本的人権は、侵すことのできない永久の権利として、現在及び将来の国民に与へられる。

詳細は API ドキュメントを参照してください。

Reference

Release files for ja-law-parser 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ja-law-parser 0.3.0
File Size Uploaded
ja_law_parser-0.3.0.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ja-law-parser 0.3.0
File Interpreter ABI Platform
ja_law_parser-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.8 kB

Release files / ja_law_parser-0.3.0.tar.gz

Download URL ja_law_parser-0.3.0.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b8ef09a798d415b8cd0b7380307974672f7612e913bf5de660508b4863ddae8a
BLAKE2b-256 checksum
How to use checksums
80992563d1a88192d200dc16f04aa7d4625fa0ca960bd0fafff2e989d869f2a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / ja_law_parser-0.3.0-py3-none-any.whl

Download URL ja_law_parser-0.3.0-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5de26fcdf5ad95e662bf2d860c6748d27443f43d433b81561568fab2c0968222
BLAKE2b-256 checksum
How to use checksums
31bdfc0ea38d1a8bb32a8657da5a376d336378d90afb47286f70ba860b1478c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page