Java Code Examples for org.apache.lucene.analysis.MockTokenizer#DEFAULT_MAX_TOKEN_LENGTH

The following examples show how to use org.apache.lucene.analysis.MockTokenizer#DEFAULT_MAX_TOKEN_LENGTH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestPackedTokenAttributeImpl.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void testPackedTokenAttributeFactory() throws Exception {
  TokenStream ts = new MockTokenizer(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, MockTokenizer.WHITESPACE, false, MockTokenizer.DEFAULT_MAX_TOKEN_LENGTH);
  ((Tokenizer)ts).setReader(new StringReader("foo bar"));
  
  assertTrue("CharTermAttribute is not implemented by Token",
    ts.addAttribute(CharTermAttribute.class) instanceof PackedTokenAttributeImpl);
  assertTrue("OffsetAttribute is not implemented by Token",
    ts.addAttribute(OffsetAttribute.class) instanceof PackedTokenAttributeImpl);
  assertTrue("PositionIncrementAttribute is not implemented by Token", 
    ts.addAttribute(PositionIncrementAttribute.class) instanceof PackedTokenAttributeImpl);
  assertTrue("TypeAttribute is not implemented by Token",
    ts.addAttribute(TypeAttribute.class) instanceof PackedTokenAttributeImpl);

  assertTrue("FlagsAttribute is not implemented by FlagsAttributeImpl",
      ts.addAttribute(FlagsAttribute.class) instanceof FlagsAttributeImpl);  
}
 
Example 2
Source File: FuzzySuggesterTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public TokenStreamComponents createComponents(String fieldName) {
  MockTokenizer tokenizer = new MockTokenizer(MockTokenizer.WHITESPACE, false, MockTokenizer.DEFAULT_MAX_TOKEN_LENGTH);
  tokenizer.setEnableChecks(true);
  TokenStream next;
  if (numStopChars != 0) {
    next = new TokenEater(preserveHoles, tokenizer, numStopChars);
  } else {
    next = tokenizer;
  }
  return new TokenStreamComponents(tokenizer, next);
}
 
Example 3
Source File: AnalyzingSuggesterTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public TokenStreamComponents createComponents(String fieldName) {
  MockTokenizer tokenizer = new MockTokenizer(MockUTF16TermAttributeImpl.UTF16_TERM_ATTRIBUTE_FACTORY,
      MockTokenizer.WHITESPACE, false, MockTokenizer.DEFAULT_MAX_TOKEN_LENGTH);
  tokenizer.setEnableChecks(true);
  TokenStream next;
  if (numStopChars != 0) {
    next = new TokenEater(preserveHoles, tokenizer, numStopChars);
  } else {
    next = tokenizer;
  }
  return new TokenStreamComponents(tokenizer, next);
}