A Japanese law parser
Project description
Japanese Law Parser
法令標準 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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for ja_law_parser-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5de26fcdf5ad95e662bf2d860c6748d27443f43d433b81561568fab2c0968222 |
|
MD5 | edeb7b4d96bd33afe1fa92196780b2d9 |
|
BLAKE2b-256 | 31bdfc0ea38d1a8bb32a8657da5a376d336378d90afb47286f70ba860b1478c6 |