本文主要是介绍一个自定义的用语过滤非字符的Lucene分析器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<strong><span style="font-size:18px;">/**** @author YangXin* @info 一个定义的用语过滤非字字符的Lucene分析器*/
package unitNine;import org.apache.lucene.analysis.Analyzer;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;import org.apache.lucene.analysis.LowerCaseFilter;
import org.apache.lucene.analysis.StopFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.WhitespaceTokenizer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.analysis.standard.StandardFilter;
import org.apache.lucene.analysis.standard.StandardTokenizer;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
import org.apache.lucene.util.Version;
public class MyAnalyzer extends Analyzer{private final Pattern alphabets = Pattern.compile("[a-z]+");@Override
这篇关于一个自定义的用语过滤非字符的Lucene分析器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!