Examples of Lexeme


Examples of org.wltea.analyzer.Lexeme

   
    for(String t : testStr){
      System.out.println(t)
      IKSegmentation ikSeg = new IKSegmentation(new StringReader(t) , true);
      try {
        Lexeme l = null;
        while( (l = ikSeg.next()) != null){
          System.out.println(l);
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

Examples of org.wltea.analyzer.Lexeme

    testStr.add("广州市越秀区广州大道中131-133号信龙大厦");
    for(String t : testStr){
      System.out.println(t)
      IKSegmentation ikSeg = new IKSegmentation(new StringReader(t) , false);
      try {
        Lexeme l = null;
        while( (l = ikSeg.next()) != null){
          System.out.println(l);
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
View Full Code Here

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

Examples of org.wltea.analyzer.core.Lexeme

  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

Examples of r194.Lexer.Lexeme

  }
 
  public void filterTokens(){
    List<Lexeme> newTokens = new ArrayList<>();
    for (int i = 0; i < tokens.size(); i++) {
      Lexeme t = tokens.get(i);
      if (t.type != Token.WHITESPACE){
        newTokens.add(t);
      }
    }
    tokens = newTokens;
View Full Code Here

Examples of r194.Lexer.Lexeme

    }
  }
 
  public Lexeme lookahead(int i) {
    if (position + i >= tokens.size()){
      return new Lexeme("", Token.EOF);
    }
    return tokens.get(position + i);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.