use std::collections::HashMap;
use crate::{ProcessType, SimpleMatcher};
#[derive(Default)]
pub struct SimpleMatcherBuilder<'a> {
word_map: HashMap<ProcessType, HashMap<u32, &'a str>>,
}
impl<'a> SimpleMatcherBuilder<'a> {
pub fn new() -> Self {
Self {
word_map: HashMap::new(),
}
}
pub fn add_word(mut self, process_type: ProcessType, word_id: u32, word: &'a str) -> Self {
let bucket = self.word_map.entry(process_type).or_default();
bucket.insert(word_id, word);
self
}
pub fn build(self) -> SimpleMatcher {
SimpleMatcher::new(&self.word_map)
}
}