Java Sensitive word filter, Java sensitive word substitution, Java sensitive Word tool class
===========================
? Copyright Sweet Potato Yiu September 25, 2017
http://www.cnblogs.com/fanshuyao/
First, the problem description
Many of the content of external websites need to filter sensitive words, avoid political and color @ emotional problems.
Second, the solution
Filter by match using Thesaurus * (asterisk)
The Java sensitive Word tool class and the sensitive word thesaurus are shown in the attachment.
1, after downloading, there are several classes, mainly for Wordfilter this tool class, using the following methods:
Java code
- Content = wordfilter.dofilter (content);//sensitive Word filtering
It's that simple.
2, a total of 2 configuration files, in the Resources folder,
sensitiveWords.txt : The word Library of sensitive words
sensitiveWordsSplitCode.txt : Separator In the middle of a sensitive word
Why there are separators, such as many people by adding delimiters or other characters between sensitive words to evade the filtering of system-sensitive words, such as:
Color @ Love (in the middle does not add @, do not let me submit) write color @ sentiment, some systems may not be filtered, and sensitiveWordsSplitCode.txt play such role, even if separated by other characters, can also be identified to filter.
Put these 2 configuration files under Src/main/resources, this is the MAVEN project, the Javaweb project is placed under SRC.
Finally, it's over.
Download the attachment and go.
Accessories: http://fanshuyao.iteye.com/blog/2394157
===========================
? Copyright Sweet Potato Yiu September 25, 2017
http://www.cnblogs.com/fanshuyao/
Java Sensitive word filter, Java sensitive word substitution, Java sensitive Word tool class