Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xml sheme 4 #12

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jplaw_data_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ license.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
japanese_law_xml_schema = "3.0.0"
japanese_law_xml_schema = "4.0.0"
serde = { version = "1.0.198", features = ["derive"] }
thiserror = "1.0.59"
69 changes: 34 additions & 35 deletions jplaw_data_types/src/article.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use japanese_law_xml_schema::{
},
sentence::SentenceElement,
suppl_provision,
text::{Text, TextElement},
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -285,6 +284,20 @@ fn article_list_from_section(
);
v.append(&mut v2)
}
SectionContents::Division(t) => {
let mut v2 = article_list_from_division(
file_id,
law_name,
part_number,
chapter_number,
seciton_number,
None,
&t.num,
suppl_provision_name,
&t.children,
);
v.append(&mut v2)
}
SectionContents::Article(t) => {
let article_index = ArticleIndex {
file_id: file_id.to_string(),
Expand Down Expand Up @@ -400,7 +413,7 @@ pub struct TextIndex {
pub paragraph: ArticleNumber,
/// 号の番号を上の階層から並べる
/// 何もないときは空
pub items: Vec<ArticleNumber>,
pub items: Vec<Option<ArticleNumber>>,
}

/// 段落のリストから文字列のリストとそのインデックスの組を生成する
Expand Down Expand Up @@ -450,7 +463,7 @@ pub fn text_list_from_paragraph(lst: &[Paragraph]) -> Vec<(TextIndex, String)> {

fn text_list_from_subitem1(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem1],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -479,7 +492,7 @@ fn text_list_from_subitem1(

fn text_list_from_subitem2(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem2],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -508,7 +521,7 @@ fn text_list_from_subitem2(

fn text_list_from_subitem3(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem3],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -537,7 +550,7 @@ fn text_list_from_subitem3(

fn text_list_from_subitem4(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem4],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -566,7 +579,7 @@ fn text_list_from_subitem4(

fn text_list_from_subitem5(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem5],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -595,7 +608,7 @@ fn text_list_from_subitem5(

fn text_list_from_subitem6(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem6],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -624,7 +637,7 @@ fn text_list_from_subitem6(

fn text_list_from_subitem7(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem7],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -653,7 +666,7 @@ fn text_list_from_subitem7(

fn text_list_from_subitem8(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem8],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -682,7 +695,7 @@ fn text_list_from_subitem8(

fn text_list_from_subitem9(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem9],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand Down Expand Up @@ -711,7 +724,7 @@ fn text_list_from_subitem9(

fn text_list_from_subitem10(
para_num: &ArticleNumber,
items: Vec<ArticleNumber>,
items: Vec<Option<ArticleNumber>>,
chldren: &[Subitem10],
) -> Vec<(TextIndex, String)> {
let mut v = Vec::new();
Expand All @@ -736,20 +749,6 @@ fn text_list_from_subitem10(
v
}

pub fn text_to_str(text: &Text) -> String {
let mut s = String::new();
for v in text.contents.iter() {
match v {
TextElement::Sub(sub) => s.push_str(&sub.text),
TextElement::Sup(sup) => s.push_str(&sup.text),
TextElement::Ruby(ruby) => s.push_str(&text_to_str(&ruby.text)),
TextElement::Line(_) => (),
TextElement::Text(str) => s.push_str(str),
}
}
s
}

pub fn sentence_element_to_str(element: &[SentenceElement]) -> String {
let mut s = String::new();
for e in element.iter() {
Expand Down Expand Up @@ -825,7 +824,7 @@ fn check_para_to_text() {
sentence: class::SentenceOrColumnOrTable::Sentence(vec![text_to_sentence(1, "元本を領収し、又は利用すること。")]),
children: Vec::new(),
struct_list: Vec::new(),
num: ArticleNumber::from_num_str("1").unwrap(),
num: Some(ArticleNumber::from_num_str("1").unwrap()),
delete: false,
hide: false
},
Expand All @@ -838,13 +837,13 @@ fn check_para_to_text() {
sentence: class::SentenceOrColumnOrTable::Sentence(vec![text_to_sentence(1, "主たる債務者の総株主の議決権(株主総会において決議をすることができる事項の全部につき議決権を行使することができない株式についての議決権を除く。以下この号において同じ。)の過半数を有する者")]),
children: Vec::new(),
struct_list: Vec::new(),
num: ArticleNumber::from_num_str("1").unwrap(),
num: Some(ArticleNumber::from_num_str("1").unwrap()),
delete: false,
hide: false
}
],
struct_list: Vec::new(),
num: ArticleNumber::from_num_str("2").unwrap(),
num: Some(ArticleNumber::from_num_str("2").unwrap()),
delete: false,
hide: false
},
Expand All @@ -853,7 +852,7 @@ fn check_para_to_text() {
sentence: class::SentenceOrColumnOrTable::Sentence(vec![text_to_sentence(1, "不動産その他重要な財産に関する権利の得喪を目的とする行為をすること。")]),
children: Vec::new(),
struct_list: Vec::new(),
num: ArticleNumber::from_num_str("3").unwrap(),
num: Some(ArticleNumber::from_num_str("3").unwrap()),
delete: false,
hide: false
}
Expand Down Expand Up @@ -907,7 +906,7 @@ fn check_para_to_text() {
eda_numbers: Vec::new(),
range_end_numbers: Vec::new()
},
items: vec![ArticleNumber{base_number: 1, eda_numbers: Vec::new(), range_end_numbers: Vec::new()}]
items: vec![Some(ArticleNumber{base_number:1,eda_numbers:Vec::new(),range_end_numbers:Vec::new()})]
},
"元本を領収し、又は利用すること。".to_string()
),
Expand All @@ -918,7 +917,7 @@ fn check_para_to_text() {
eda_numbers: Vec::new(),
range_end_numbers: Vec::new()
},
items: vec![ArticleNumber{base_number: 2, eda_numbers: Vec::new(), range_end_numbers: Vec::new()}]
items: vec![Some(ArticleNumber{base_number:2,eda_numbers:Vec::new(),range_end_numbers:Vec::new()})]
},
"主たる債務者が法人である場合の次に掲げる者".to_string()
),
Expand All @@ -929,8 +928,8 @@ fn check_para_to_text() {
eda_numbers: Vec::new(),
range_end_numbers: Vec::new()
},
items: vec![ArticleNumber{base_number: 2, eda_numbers: Vec::new(), range_end_numbers: Vec::new()},
ArticleNumber{base_number: 1, eda_numbers: Vec::new(), range_end_numbers: Vec::new()}]
items: vec![Some(ArticleNumber{base_number:2,eda_numbers:Vec::new(),range_end_numbers:Vec::new()}),
Some(ArticleNumber{base_number:1,eda_numbers:Vec::new(),range_end_numbers:Vec::new()})]
},
"主たる債務者の総株主の議決権(株主総会において決議をすることができる事項の全部につき議決権を行使することができない株式についての議決権を除く。以下この号において同じ。)の過半数を有する者".to_string()
),
Expand All @@ -941,7 +940,7 @@ fn check_para_to_text() {
eda_numbers: Vec::new(),
range_end_numbers: Vec::new()
},
items: vec![ArticleNumber{base_number: 3, eda_numbers: Vec::new(), range_end_numbers: Vec::new()}]
items: vec![Some(ArticleNumber{base_number:3,eda_numbers:Vec::new(),range_end_numbers:Vec::new()})]
},
"不動産その他重要な財産に関する権利の得喪を目的とする行為をすること。".to_string()
),
Expand Down