trie/trie.rs
1use html_keywords_matching::{MatchResult, Trie};
2
3fn main() {
4 let mut trie = Trie::new();
5 trie.build(vec![
6 "openai".to_string(),
7 "stack overflow".to_string(),
8 "prompt engineering".to_string(),
9 ]);
10
11 // read from test.html
12 let read = std::fs::read_to_string("examples/test.html").unwrap();
13
14 let res: MatchResult = trie.search_replace(&read);
15
16 println!("{:?}", res.match_words);
17
18 // save res.text to test_modify.html
19 std::fs::write("examples/test_modify.html", res.modified_html).unwrap();
20}