From: Sondre Wold Date: Wed, 1 May 2024 18:03:50 +0000 (+0200) Subject: Remove double filter X-Git-Url: https://letsjmore.com/?a=commitdiff_plain;h=87864b202e7b308c9182e79e1cff4adf5c62a540;p=mitok.git Remove double filter --- 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"];