Package org.apache.lucene.analysis

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


   
    nextToken = TokenUtils.nextToken(input, reusableToken);
   
    if(nextToken != null &&
        (Word.TYPE_LETTER_OR_DIGIT.equalsIgnoreCase(nextToken.type())
          || Word.TYPE_DIGIT_OR_LETTER.equalsIgnoreCase(nextToken.type()))
        ) {
      final char[] buffer = nextToken.buffer();
      final int length = nextToken.length();
      byte lastType = (byte) Character.getType(buffer[0])//与上次的字符是否同类
      int termBufferOffset = 0;
View Full Code Here


    clearAttributes();
    Token token = nextToken(reusableToken);
    if(token != null) {
      termAtt.copyBuffer(token.buffer(), 0, token.length());
      offsetAtt.setOffset(token.startOffset(), token.endOffset());
      typeAtt.setType(token.type());
      return true;
    } else {
      end();
      return false;
    }
View Full Code Here

            final List<Token> expected = actualTokens.get(term).get(docIDToID.get(doc));
            //System.out.println("      doc=" + docIDToID.get(doc) + " " + expected.size() + " freq");
            assertNotNull(expected);
            assertEquals(expected.size(), docsAndPositionsAndOffsets.freq());
            for(Token token : expected) {
              int pos = Integer.parseInt(token.type());
              //System.out.println("        pos=" + pos);
              assertEquals(pos, docsAndPositionsAndOffsets.nextPosition());
              assertEquals(token.startOffset(), docsAndPositionsAndOffsets.startOffset());
              assertEquals(token.endOffset(), docsAndPositionsAndOffsets.endOffset());
            }
View Full Code Here

            final List<Token> expected = actualTokens.get(term).get(docIDToID.get(doc));
            //System.out.println("      doc=" + docIDToID.get(doc) + " " + expected.size() + " freq");
            assertNotNull(expected);
            assertEquals(expected.size(), docsAndPositions.freq());
            for(Token token : expected) {
              int pos = Integer.parseInt(token.type());
              //System.out.println("        pos=" + pos);
              assertEquals(pos, docsAndPositions.nextPosition());
            }
          }
View Full Code Here

    final Token reusableToken = new Token();
    Token nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html#news",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html#news") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html?b=c") == true);
View Full Code Here

    final Token reusableToken = new Token();
    Token nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html#news",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html#news") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html?b=c") == true);
View Full Code Here

    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html?b=c") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "https://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("https://lucene.apache.org/java/docs/index.html?b=c") == true);
View Full Code Here

    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "http://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("http://lucene.apache.org/java/docs/index.html?b=c") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "https://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("https://lucene.apache.org/java/docs/index.html?b=c") == true);
View Full Code Here

    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "https://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("https://lucene.apache.org/java/docs/index.html?b=c") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);

    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is not null and it should be", nextToken == null);
View Full Code Here

    tf.next(reusableToken);//skip here
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);
    assertTrue(nextToken.term() + " is not equal to " + "https://lucene.apache.org/java/docs/index.html?b=c",
            nextToken.term().equals("https://lucene.apache.org/java/docs/index.html?b=c") == true);
    assertTrue(nextToken.type() + " is not equal to " + WikipediaTokenizer.EXTERNAL_LINK_URL, nextToken.type().equals(WikipediaTokenizer.EXTERNAL_LINK_URL) == true);
    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is null and it shouldn't be", nextToken != null);

    nextToken = tf.next(reusableToken);
    assertTrue("nextToken is not null and it should be", nextToken == null);
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.