diff --git a/src/constants.rs b/src/constants.rs index 42a2c5d..f5fb834 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -63,11 +63,12 @@ pub static NEGATIVE: Lazy = Lazy::new(|| { pub static TITLE_SEPARATOR: Lazy = Lazy::new(|| Regex::new(r#" [-|—\\/>»] "#).expect("TITLE_SEPARATOR regex")); -pub static TITLE_CUT_END: Lazy = Lazy::new(|| +pub static TITLE_CUT_END: Lazy = Lazy::new(|| { RegexBuilder::new(r#"(.*)[-|—\\/>»] .*"#) - .case_insensitive(true) - .build() - .expect("TITLE_CUT_END regex")); + .case_insensitive(true) + .build() + .expect("TITLE_CUT_END regex") +}); pub static WORD_COUNT: Lazy = Lazy::new(|| Regex::new(r#"\s+"#).expect("WORD_COUNT regex")); pub static TITLE_CUT_FRONT: Lazy = Lazy::new(|| { RegexBuilder::new(r#"[^-|\\/>»]*[-|\\/>»](.*)"#) diff --git a/src/util.rs b/src/util.rs index e561e73..1b6cadf 100644 --- a/src/util.rs +++ b/src/util.rs @@ -317,8 +317,14 @@ impl Util { pub fn text_similarity(a: &str, b: &str) -> f64 { let a = a.to_lowercase(); let b = b.to_lowercase(); - let tokens_a = constants::TOKENIZE.split(&a).filter(|token| !token.is_empty()).collect::>(); - let tokens_b = constants::TOKENIZE.split(&b).filter(|token| !token.is_empty()).collect::>(); + let tokens_a = constants::TOKENIZE + .split(&a) + .filter(|token| !token.is_empty()) + .collect::>(); + let tokens_b = constants::TOKENIZE + .split(&b) + .filter(|token| !token.is_empty()) + .collect::>(); if tokens_a.is_empty() || tokens_b.is_empty() { return 0.0; }