本文整理匯總了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();
}
示例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;
}
示例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));
}