當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexAnalysis類代碼示例

本文整理匯總了Java中org.ansj.splitWord.analysis.IndexAnalysis的典型用法代碼示例。如果您正苦於以下問題:Java IndexAnalysis類的具體用法?Java IndexAnalysis怎麽用?Java IndexAnalysis使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IndexAnalysis類屬於org.ansj.splitWord.analysis包,在下文中一共展示了IndexAnalysis類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.ansj.splitWord.analysis.IndexAnalysis; //導入依賴的package包/類
public static void main(String[] args) throws IOException {
	List<Term> parse = ToAnalysis.parse("中華人民 共和國 成立了 ");
	System.out.println(parse);
	List<Term> parse1 = IndexAnalysis.parse("你吃過飯了沒有!!!!!吃過無妨論文");
	
  
	//System.out.println(parse1);
	String text11="ZW321282050000000325";
	
	Tokenizer tokenizer = new AnsjTokenizer(new StringReader(text11), 0, true);
	CharTermAttribute termAtt = tokenizer.addAttribute(CharTermAttribute.class);
	OffsetAttribute offsetAtt = 
			tokenizer.addAttribute(OffsetAttribute.class);
		PositionIncrementAttribute positionIncrementAtt = 
			tokenizer.addAttribute(PositionIncrementAttribute.class);

    tokenizer.reset();
	while (tokenizer.incrementToken()){

	      System.out.print(new String(termAtt.toString()+" ") );
		//  System.out.print( offsetAtt.startOffset() + "-" + offsetAtt.endOffset() + "-" );
		//System.out.print( positionIncrementAtt.getPositionIncrement() +"/");

	}
	tokenizer.close();
}
 
開發者ID:dimensoft,項目名稱:improved-journey,代碼行數:27,代碼來源:TestAnsj.java

示例2: createComponents

import org.ansj.splitWord.analysis.IndexAnalysis; //導入依賴的package包/類
@Override
protected TokenStreamComponents createComponents(String fieldName,
		Reader reader) {
	final Tokenizer source = new AnsjTokenizer(reader,new IndexAnalysis(reader));
	
	TokenStreamComponents result;
	if (stopwords.isEmpty()) {
		result = new TokenStreamComponents(source);
	} else {
		result = new TokenStreamComponents(source,new StopFilter(matchVersion, source, stopwords));
	}
	
	return result;
}
 
開發者ID:flash0729,項目名稱:ansj-seg-for-lucene3,代碼行數:15,代碼來源:AnsjIndexAnalyzer.java

示例3: AnsjAnalyzer

import org.ansj.splitWord.analysis.IndexAnalysis; //導入依賴的package包/類
/**
    * @param analysis 
    *            搜索時用精準分詞,索引時用麵向索引的分詞,默認值為麵向索引的分詞
    */
public AnsjAnalyzer(final Version matchVersion, Class<? extends Analysis> analysis, final Set<?> stopwords) {
	this.matchVersion = matchVersion;
	this.analysis = analysis == null ? IndexAnalysis.class : analysis;
	// analyzers should use char array set for stopwords!
    this.stopwords = stopwords == null ? CharArraySet.EMPTY_SET : CharArraySet
        .unmodifiableSet(CharArraySet.copy(matchVersion, stopwords));
}
 
開發者ID:flash0729,項目名稱:ansj-seg-for-lucene3,代碼行數:12,代碼來源:AnsjAnalyzer.java


注:本文中的org.ansj.splitWord.analysis.IndexAnalysis類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。