Sensitive-rs
English | 简体中文
A high-performance Rust crate for multi-pattern string matching, validation, filtering, and replacement.
Features
- Find all sensitive words:
find_all - Validate text contains sensitive words:
validate - Remove sensitive words:
filter - Replace sensitive words with a character:
replace - Multi-algorithm engine: Aho-Corasick, Wu-Manber, Regex
- Noise removal via configurable regex
- Variant detection (拼音、形似字)
- Parallel search with
rayon - LRU cache for hot queries
- Batch processing:
find_all_batch - Layered matching:
find_all_layered - Streaming processing:
find_all_streaming
Installation
Add to your Cargo.toml:
[]
= "0.7.0"
Quick Start
use Filter;
Advanced Usage
Batch processing:
let texts = vec!;
let results = filter.find_all_batch;
Layered matching:
let layered = filter.find_all_layered;
Streaming large files:
use File;
use BufReader;
let reader = new;
let stream_results = filter.find_all_streaming ?;
CLI Usage
Install with the cli feature:
[]
= { = "0.7.0", = ["cli"] }
Or install directly:
Both sensitive and sensitive-rs commands are available after installation.
Commands
# Find sensitive words
# Validate (exit 1 if sensitive words found)
# Replace sensitive words
# Remove sensitive words
# Read from file
# Pipe from stdin
|
Options
--dict <path>— custom dictionary file--dict-all— use extended dictionary (27k words)--algorithm <algo>— force algorithm:aho-corasick,wumanber,regex--variant— enable pinyin and shape variant detection--noise-pattern <regex>— custom noise removal regex--json— JSON output format--color— force colored output
Documentation
For detailed documentation, please refer to Documentation.
License
Licensed under either of
- Apache License, Version 2.0, LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0
- MIT license LICENSE-MIT or http://opensource.org/licenses/MIT
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 or MIT license, shall be dual licensed as above, without any additional terms or conditions.