diff --git a/README.md b/README.md index 32e9d41..0749d37 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ RISolve ## Tests - Getting paragraphs from `law_id` (`risparser::overview::test::parse()`) - Create file `law_id` in `./data/expected/overview` (then run tests to get current output + save in file) +- Parsing paragraphs: add test in `src/risparser/paragraph/mod.rs` +- # Features (to be moved to lib.rs one-by-one) diff --git a/src/law/mod.rs b/src/law/mod.rs index 93f0035..e9147d0 100644 --- a/src/law/mod.rs +++ b/src/law/mod.rs @@ -135,32 +135,6 @@ impl PartialEq for LawBuilder { } impl LawBuilder { - //#[cfg(test)] - //pub fn test(name: &str) -> Self { - // let mut classifiers = Vec::new(); - - // if name == "new" { - // classifiers.push(Classifier::new("a", Arc::new(&contains)).root()); - // classifiers.push(Classifier::new("b", Arc::new(&contains))); - // classifiers.push(Classifier::new("c", Arc::new(&contains))); - // classifiers.push(Classifier::new("d", Arc::new(&contains))); - // } else if name == "UrhG" { - // classifiers.push(Classifier::new("Hauptstück", Arc::new(&contains)).root()); - // classifiers.push(Classifier::new("Abschnitt", Arc::new(&contains))); - // classifiers.push(Classifier::new("Number", Arc::new(&starts_with_number))); - // } - - // Self { - // name: name.into(), - // classifiers, - // header: Vec::new(), - // next_para_header: None, - // last_instance: None, - // #[cfg(test)] - // history: Vec::new(), - // } - //} - /// Creates a new law builder. Adds classifier for known law texts. pub fn new(name: &str) -> Self { Self { @@ -172,15 +146,6 @@ impl LawBuilder { #[cfg(test)] history: Vec::new(), } - - //let paragraphs = overview::parse(law_id.unwrap()).unwrap(); - - //for paragraph in tqdm::tqdm(paragraphs.into_iter()) { - // let cont = paragraph::parse(¶graph, &mut builder).unwrap(); - // if !cont { - // break; - // } - //} } pub fn add_classifier(&mut self, classifier: Classifier) { @@ -460,95 +425,3 @@ impl Display for Content { } } } - -//#[cfg(test)] -//mod tests { -// use pretty_assertions::assert_eq; -// use std::{ -// fs::File, -// io::{self, BufRead, Read}, -// path::Path, -// }; -// -// use super::*; -// -// fn read_lines

(filename: P) -> io::Result> -// where -// P: AsRef, -// { -// let file = File::open(filename)?; -// let buf_reader = io::BufReader::new(file); -// buf_reader.lines().collect() -// } -// -// #[ignore] -// #[test] -// fn test_with_live_data() { -// let law: Law = LawBuilder::new("UrhG").into(); -// -// let path = Path::new("./data/urhg/builder.result"); -// let mut file = File::open(path).unwrap(); -// let mut json = String::new(); -// file.read_to_string(&mut json).unwrap(); -// -// let expected: Law = serde_json::from_str(&json).unwrap(); -// -// assert_eq!(law, expected); -// } -// -// #[ignore] -// #[test] -// fn test_stgb_with_live_data() { -// let law: Law = LawBuilder::new("StGB").into(); -// -// let path = Path::new("./data/stgb/builder.result"); -// let mut file = File::open(path).unwrap(); -// let mut json = String::new(); -// file.read_to_string(&mut json).unwrap(); -// -// let expected: Law = serde_json::from_str(&json).unwrap(); -// -// //println!("{}", serde_json::to_string(&law).unwrap()); -// -// assert_eq!(law, expected); -// } -// -// #[test] -// fn test_builder_full_urhg() { -// let mut builder = LawBuilder::test("UrhG"); -// -// let path = Path::new("./data/urhg/par"); -// let input = read_lines(path.join("../par.result")).unwrap(); -// -// for i in input { -// let (command, content) = i.split_once(":").unwrap(); -// -// match command { -// "New_header" => builder.new_header(content), -// "New desc" => builder.new_desc(content), -// "New_new_para_header" => builder.new_next_para_header(content), -// "New_par" => { -// let (par, real_content) = i.split_once(";").unwrap(); -// let (_, real_par) = par.split_once(":").unwrap(); -// let real_content: Content = serde_json::from_str(real_content).unwrap(); -// builder.new_par(real_par.trim().into(), real_content); -// } -// _ => { -// panic!("Don't know command '{command}'"); -// } -// } -// } -// -// let actual: Law = builder.into(); -// -// //println!("{}", serde_json::to_string(&law).unwrap()); -// -// let mut file = File::open(path.join("../builder.result")).unwrap(); -// let mut json = String::new(); -// file.read_to_string(&mut json).unwrap(); -// -// let expected = serde_json::from_str(&json).unwrap(); -// -// assert_eq!(actual, expected); -// } -//}