General Introduction
Sensitive word filtering tool (Sensitive Word) is a high-performance Java sensitive word filtering tool based on the implementation of the DFA algorithm framework. The tool can efficiently detect and filter sensitive words , support for multiple format conversion and custom replacement strategies. Its design goal is to provide an easy to use and superior performance of the sensitive word filtering solution for a variety of application scenarios .
Function List
- Sensitive word detection: support sensitive word judgment, return, desensitization and other operations
- Format Conversion: Support full- and half-corner conversion, traditional and simplified Chinese conversion, English case conversion, etc.
- Customized Replacement: Support user-defined sensitive words and replacement strategies
- Dynamic update: Support the dynamic update of the sensitive words database, real-time effective
- Tag interface: support for tag management of sensitive words
- Special Character Handling: Supports flexible matching by skipping special characters
Using Help
Installation process
- Preparing the environment: Ensure that JDK 1.8+ and Maven 3.x+ are installed.
- Introducing dependencies: In the project's
pom.xml
file to add the following dependencies:<dependency> <groupId>com.github.houbb</pgroupId> <artifactId>sensitive-word</partifactId> <version>0.19.2</pversion> </pdependency>
- initialization: Initialize the SensitiveWordHelper class in the project.
Usage
- Sensitive word detection::
String text = "Text content to be detected"; boolean contains = SensitiveWordHelper.contains(text);
This method returns a boolean value indicating whether the text contains sensitive words.
- sensitive word replacement::
String replacedText = SensitiveWordHelper.replace(text, '*');
This method replaces sensitive words in the text with the specified characters.
- Get all sensitive words::
List sensitiveWords = SensitiveWordHelper.findAll(text);
This method returns a list of all sensitive words in the text.
- Customized Sensitive Phrase Bank::
SensitiveWordHelper.addSensitiveWord("Customized sensitive words");
This method allows users to dynamically add sensitive words.
Detailed Operation Procedure
- Initialize Sensitive Word Database: Load the default sensitive lexicon or a customized sensitive lexicon at project startup.
- text detection: In the text content that needs to be detected call the
SensitiveWordHelper.contains
method to determine if it contains sensitive words. - sensitive word processing: Choose to use, based on business needs, the
replace
method for sensitive word substitution, or use thefindAll
method to get all the sensitive words for further processing. - dynamic update (Internet): During operation, the
addSensitiveWord
The method dynamically updates the sensitive word database to ensure real-time and accurate detection of sensitive words.