Java中文分词包 + Redis 做一个简易的 敏感词查询接口

首先有 敏感词 词库,存到Redis 中;

用String类型,词做 key ,vaule 为 空;

然后对文章进行分词, 分词逐个查询在Redis中是否包含某key,就是检查 文章中 是否包含敏感词

中文分词包使用的是如下类

import java.io.IOException;

import java.io.StringReader;

import org.wltea.analyzer.core.IKSegmenter;

import org.wltea.analyzer.core.Lexeme;

public class Test3 {

public static void main(String[] args) throws IOException {

String text="某文章...";

StringReader sr=new StringReader(text);

IKSegmenter ik=new IKSegmenter(sr, true);

Lexeme lex=null;

while((lex=ik.next())!=null){

System.out.println(lex.getLexemeText());

}

}

}

原文地址:https://www.cnblogs.com/cjd01/p/14087914.html