teaql-tool-std 0.1.1

Zero-dependency standard utilities for the TeaQL Tool ecosystem.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use teaql_tool_std::filter::FilterTool;

#[test]
fn test_filter_operations() {
    let tool = FilterTool::new();
    let words = vec!["badword", "ugly"];
    let trie = tool.build_trie(&words);
    
    let text1 = "this is a badword!";
    let text2 = "this is very nice!";
    
    assert!(tool.contains_sensitive(text1, &trie));
    assert!(!tool.contains_sensitive(text2, &trie));
    
    let replaced = tool.replace_sensitive(text1, &trie, "***");
    assert_eq!(replaced, "this is a ***!");
}