restructure + update readme
All checks were successful
CI/CD Pipeline / test (push) Successful in 33s
All checks were successful
CI/CD Pipeline / test (push) Successful in 33s
This commit is contained in:
parent
8e058122d6
commit
c6de1fe180
@ -10,6 +10,8 @@ RISolve
|
|||||||
## Tests
|
## Tests
|
||||||
- Getting paragraphs from `law_id` (`risparser::overview::test::parse()`)
|
- 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)
|
- 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)
|
# Features (to be moved to lib.rs one-by-one)
|
||||||
|
127
src/law/mod.rs
127
src/law/mod.rs
@ -135,32 +135,6 @@ impl PartialEq for LawBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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.
|
/// Creates a new law builder. Adds classifier for known law texts.
|
||||||
pub fn new(name: &str) -> Self {
|
pub fn new(name: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -172,15 +146,6 @@ impl LawBuilder {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
history: Vec::new(),
|
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) {
|
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<P>(filename: P) -> io::Result<Vec<String>>
|
|
||||||
// where
|
|
||||||
// P: AsRef<Path>,
|
|
||||||
// {
|
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user