From d2c8db3aa5df79ecd07182462a47a57bdbf92b44 Mon Sep 17 00:00:00 2001 From: TabulateJarl8 Date: Thu, 7 Jul 2022 12:37:21 -0400 Subject: [PATCH] remove rust version of test as it is slower --- tests/checkduplicates/Cargo.toml | 13 ------ tests/checkduplicates/src/main.rs | 69 ------------------------------- 2 files changed, 82 deletions(-) delete mode 100644 tests/checkduplicates/Cargo.toml delete mode 100644 tests/checkduplicates/src/main.rs diff --git a/tests/checkduplicates/Cargo.toml b/tests/checkduplicates/Cargo.toml deleted file mode 100644 index 6b3fe91..0000000 --- a/tests/checkduplicates/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "checkduplicates" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -project-root = "0.2.2" -itertools = "0.10.3" -indicatif = "0.16.2" -num-integer = "0.1.45" -fuzzywuzzy = "0.0.2" diff --git a/tests/checkduplicates/src/main.rs b/tests/checkduplicates/src/main.rs deleted file mode 100644 index d170c9a..0000000 --- a/tests/checkduplicates/src/main.rs +++ /dev/null @@ -1,69 +0,0 @@ -use std::{ - process::Command, - path::PathBuf, - io::{BufReader, BufRead}, - fs::File, -}; -use itertools::Itertools; -use indicatif::ProgressBar; -use fuzzywuzzy::fuzz; - - -fn lines_from_file(filename: &PathBuf, comment: String) -> Vec<(String, String)> { - let file = File::open(filename).expect("no such file"); - let buf = BufReader::new(file); - buf.lines() - .map(|l| { (l.expect("Could not parse line"), comment.clone()) }) - .collect() -} - -fn partial_match(x_fact: &str, y_fact: &str) -> Option { - let ratio: u8 = fuzz::partial_token_sort_ratio(x_fact, y_fact, true, true); - if ratio > 80 { - return Some(ratio); - } - None -} - -fn main() { - // get project's top level - let output = Command::new("git") - .args(&["rev-parse", "--show-toplevel"]) - .output() - .expect("failed to execute git process"); - - if !output.status.success() { - panic!("Error: {}", String::from_utf8_lossy(&output.stderr)); - } - - // read safe.txt and unsafe.txt into lists - let mut project_root: PathBuf = PathBuf::from(String::from_utf8(output.stdout).unwrap().trim()); - project_root.push("randfacts"); - project_root.push("safe.txt"); - - let mut all_facts = lines_from_file(&project_root, String::from("safe")); - - - project_root.pop(); - project_root.push("unsafe.txt"); - - let mut unsafe_contents = lines_from_file(&project_root, String::from("unsafe")); - - all_facts.append(&mut unsafe_contents); - - // Generate all possible pairs of the facts from safe.txt and unsafe.txt - // combined - let mut matches: Vec = vec![]; - let pb = ProgressBar::new(num_integer::binomial(all_facts.len() as u64, 2)); - let combinations = all_facts.into_iter().combinations(2); - - // iterate through all the combinations - for (index, facts) in combinations.enumerate() { - match partial_match(&facts[0].0, &facts[0].1) { - Some(s) => matches.push(s), - None => (), - } - pb.inc(1) - } - -} \ No newline at end of file