本文整理汇总了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));
}