paoding分词TokenStream的使用


import java.io.IOException;
import java.io.StringReader;

import net.paoding.analysis.analyzer.PaodingAnalyzer;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.Token;
import org.apache.lucene.analysis.TokenStream;

public class PaodingTokenTest
{
	public static void main(String[] args)
	{
		
		String content = "中华人民共和国";
		Analyzer analyzer = new PaodingAnalyzer();
		
		TokenStream tokenStream2 = analyzer.tokenStream("", new StringReader(
				content));
        Token t;
		try { 
			while ((t = tokenStream2.next()) != null) {
				System.out.println(t.termText());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



result:中华 华人 人民 共和 共和国

你可能感兴趣的:(java,apache,.net,Lucene)