Skip to main content

A Japanese law parser

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ja_law_parser-0.3.0.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

ja_law_parser-0.3.0-py3-none-any.whl (16.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page