Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Ja Law Parser
https://github.com/takuyaa/ja-law-parser
Admin
A Japanese law parser
Tokens:
467
Snippets:
3
Trust Score:
9.5
License:
MIT
Update:
5 months ago
Context
Chat
Benchmark
21
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Install ja-law-parser using poetry Source: https://github.com/takuyaa/ja-law-parser/blob/main/README.md This command adds the `ja-law-parser` library as a dependency to your project using the poetry dependency manager, integrating it into your project's virtual environment. ```shell poetry add ja-law-parser ``` -------------------------------- ### Install ja-law-parser using pip Source: https://github.com/takuyaa/ja-law-parser/blob/main/README.md This command installs the `ja-law-parser` library and its dependencies using the pip package manager, making it available for use in your Python projects. ```shell pip install ja-law-parser ``` -------------------------------- ### Parse Japanese Law XML and access elements Source: https://github.com/takuyaa/ja-law-parser/blob/main/README.md This example demonstrates how to initialize the `LawParser`, parse a Japanese law XML file (e.g., the Constitution), and access various structural elements like the law title, chapters, articles, and paragraphs using the Pydantic models provided by the library. It showcases how to navigate the parsed law structure to extract specific text content. ```python 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) # => この憲法が国民に保障する基本的人権は、侵すことのできない永久の権利として、現在及び将来の国民に与へられる。 ```