Package org.wltea.analyzer.core

Examples of org.wltea.analyzer.core.Lexeme


  private static List<Lexeme> doAnalyze(String keywords){
    List<Lexeme> lexemes = new ArrayList<Lexeme>();

    IKSegmenter ikSeg = new IKSegmenter(new StringReader(keywords));
    try{
      Lexeme l = null;
      while( (l = ikSeg.next()) != null){
        lexemes.add(l);
      }
    }catch(IOException e){
      e.printStackTrace();
View Full Code Here


  public boolean incrementToken() throws IOException {
    //清除所有的词元属性
    clearAttributes();
        skippedPositions = 0;

        Lexeme nextLexeme = _IKImplement.next();
    if(nextLexeme != null){
            posIncrAtt.setPositionIncrement(skippedPositions +1 );

      //将Lexeme转成Attributes
      //设置词元文本
      termAtt.append(nextLexeme.getLexemeText());
      //设置词元长度
      termAtt.setLength(nextLexeme.getLength());
      //设置词元位移
//      offsetAtt.setOffset(nextLexeme.getBeginPosition(), nextLexeme.getEndPosition());
            offsetAtt.setOffset(correctOffset(nextLexeme.getBeginPosition()), correctOffset(nextLexeme.getEndPosition()));

            //记录分词的最后位置
      endPosition = nextLexeme.getEndPosition();
      //记录词元分类
      typeAtt.setType(nextLexeme.getLexemeTypeString());     
      //返会true告知还有下个词元
      return true;
    }
    //返会false告知词元输出完毕
    return false;
View Full Code Here

TOP

Related Classes of org.wltea.analyzer.core.Lexeme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.