Java Sensitive word filter, Java sensitive word substitution, Java sensitive Word tool class

Source: Internet
Author: User

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
    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.