diff --git a/src/main.rs b/src/main.rs index bbdb7e5..a0b6f33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ use std::sync::{ }; use std::time::Duration; -use aho_corasick::AhoCorasick; +use aho_corasick::{AhoCorasick, AhoCorasickKind, MatchKind}; use clap::Parser; use dashmap::DashMap; use indicatif::{ProgressBar, ProgressState, ProgressStyle}; @@ -47,7 +47,14 @@ static KEYWORDS: &[&str] = &[ "物联网", "机器学习", ]; -static ANALYZER: Lazy = Lazy::new(|| AhoCorasick::new(KEYWORDS.iter()).unwrap()); +static ANALYZER: Lazy = Lazy::new(|| { + AhoCorasick::builder() + .kind(Some(AhoCorasickKind::DFA)) + .match_kind(MatchKind::Standard) + .prefilter(true) + .build(KEYWORDS.iter()) + .unwrap() +}); #[derive(Parser, Debug)] #[command(version, about, long_about = None)]