From 87864b202e7b308c9182e79e1cff4adf5c62a540 Mon Sep 17 00:00:00 2001 From: Sondre Wold Date: Wed, 1 May 2024 20:03:50 +0200 Subject: [PATCH] Remove double filter --- mitok/src/lib.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mitok/src/lib.rs b/mitok/src/lib.rs index 324d151..da5e82b 100644 --- a/mitok/src/lib.rs +++ b/mitok/src/lib.rs @@ -29,8 +29,7 @@ pub fn tokenize(contents: &str) -> Vec> { let mut tokens = Vec::new(); let sentences: Vec<_> = contents .split(&['.', '!', '?']) - .filter(|c| !c.is_empty()) - .filter(|c| c.len() > 1) + .filter(|c| !c.is_empty() && c.len() > 1) .collect(); for sentence in sentences { let raw_tokens: Vec<&str> = sentence.split(" ").filter(|t| !t.is_empty()).collect(); @@ -54,7 +53,6 @@ mod tests { fn single_sentence() { let contents = "\ dette er en banal test"; - let mut left_side = Vec::new(); let c = vec!["dette", "er", "en", "banal", "test"]; left_side.push(c); @@ -66,7 +64,6 @@ mod tests { fn multiple_sentences() { let contents = "\ Dette er den første setningen. Dette er den andre setningen."; - let mut left_side = Vec::new(); let c1 = vec!["Dette", "er", "den", "første", "setningen"]; let c2 = vec!["Dette", "er", "den", "andre", "setningen"]; -- 2.39.5