Sensitive-word is a Java library for detecting and filtering sensitive content based on the DFA algorithm.
The tool addresses the need to identify and handle sensitive words, profanity, and prohibited content in text. It uses a Deterministic Finite Automaton algorithm to achieve high-performance matching, supporting operations like detection, replacement, and desensitization of sensitive terms. The library includes a built-in word list and supports word classification and tagging. Beyond basic filtering, it handles format conversions including full-width to half-width character swapping, simplified to traditional Chinese conversion, and pinyin conversion. It also supports fuzzy matching and can detect patterns beyond sensitive words, such as email addresses, numbers, URLs, and IPv4 addresses.
The tool suits Java applications requiring content moderation at scale, particularly those serving Chinese-language audiences given its focus on Chinese character handling. It works well for user-generated content platforms, messaging systems, and any service needing to enforce content policies. The library offers flexibility through custom replacement strategies, user-defined word lists, and whitelist support. Users can dynamically update word lists at runtime without reinitializing the entire system, and can add or remove individual words without full reloading. The fluent API design aims for straightforward integration.
The project shows active maintenance with ongoing expansion of the word list and algorithm optimization. The maintainer actively solicits community contributions through pull requests and maintains a technical discussion group for user support and feedback. A companion admin console application exists in early development stages to support word list management.