Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.Token.termLength()


                            Fieldable[] fields = aDoc.getFieldables(FieldNames.PROPERTIES);
                            Token t = new Token();
                            for (Fieldable field : fields) {
                                // assume properties fields use SingleTokenStream
                                t = field.tokenStreamValue().next(t);
                                String value = new String(t.termBuffer(), 0, t.termLength());
                                if (value.startsWith(namePrefix)) {
                                    // extract value
                                    value = value.substring(namePrefix.length());
                                    // create new named value
                                    Path p = getRelativePath(state, propState);
View Full Code Here


                            Token t = new Token();
                            for (int k = 0; k < fields.length; k++) {
                                Fieldable field = fields[k];
                                // assume properties fields use SingleTokenStream
                                t = field.tokenStreamValue().next(t);
                                String value = new String(t.termBuffer(), 0, t.termLength());
                                if (value.startsWith(namePrefix)) {
                                    // extract value
                                    value = value.substring(namePrefix.length());
                                    // create new named value
                                    Path p = getRelativePath(state, propState);
View Full Code Here

          best.put(inputToken, theSuggestions.keySet().iterator().next());
        }
        if (hasFreqInfo) {
          isCorrectlySpelled = isCorrectlySpelled && spellingResult.getTokenFrequency(inputToken) > 0;
        }
        result.add(new String(inputToken.termBuffer(), 0, inputToken.termLength()), suggestionList);
      }
    }
    if (hasFreqInfo) {
      result.add("correctlySpelled", isCorrectlySpelled);
    } else if(extendedResults && suggestions.size() == 0) { // if the word is misspelled, its added to suggestions with freqinfo
View Full Code Here

    TokenStream tokens = analyzer.reusableTokenStream( "", new StringReader( query ) );
    tokens.reset();
   
    Token token = tokens.next();
    while( token != null ) {
      norm.append( new String(token.termBuffer(), 0, token.termLength()) );
      token = tokens.next();
    }
    return norm.toString();
  }
View Full Code Here

      // be safe to use the next(Token) method.
      t = input.next(in);
      if (t == null) return null;

      char [] termBuffer = t.termBuffer();
      int len = t.termLength();
      int start=0;
      if (len ==0) continue;

      int posInc = t.getPositionIncrement();
      origPosIncrement += posInc;
View Full Code Here

    Token tok=null;
    for (int i=start; i<end; i++) {
      tok = lst.get(i);
      if (catenateSubwords) {
        if (i==start) firstTok=tok;
        sb.append(tok.termBuffer(), 0, tok.termLength());
      }
      if (generateSubwords) {
        queue.add(tok);
      }
    }
View Full Code Here

        if (lst.size() == 0)
          return null;
        else if (lst.size() == 1) {
          t = lst.get(0);
          return new TermQuery(new Term(field, new String(t.termBuffer(), 0, t.termLength())));
        } else {
          if (severalTokensAtSamePosition) {
            if (positionCount == 1) {
              // no phrase query:
              BooleanQuery q = new BooleanQuery(true);
View Full Code Here

              // no phrase query:
              BooleanQuery q = new BooleanQuery(true);
              for (int i = 0; i < lst.size(); i++) {
                t = (org.apache.lucene.analysis.Token) lst.get(i);
                TermQuery currentQuery = new TermQuery(
                        new Term(field, new String(t.termBuffer(), 0, t.termLength())));
                q.add(currentQuery, BooleanClause.Occur.SHOULD);
              }
              return q;
            }
            else {
View Full Code Here

                t = (org.apache.lucene.analysis.Token) lst.get(i);
                if (t.getPositionIncrement() == 1 && multiTerms.size() > 0) {
                  mpq.add((Term[])multiTerms.toArray(new Term[0]));
                  multiTerms.clear();
                }
                multiTerms.add(new Term(field, new String(t.termBuffer(), 0, t.termLength())));
              }
              mpq.add((Term[])multiTerms.toArray(new Term[0]));
              return mpq;
            }
          }
View Full Code Here

          else {
            PhraseQuery q = new PhraseQuery();
            q.setSlop(phraseSlop);
            for (int i = 0; i < lst.size(); i++) {
              Token token = lst.get(i);
              q.add(new Term(field, new String(token.termBuffer(), 0, token.termLength())));
            }
            return q;
          }
        }
      }
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.