Java Code Examples for org.apache.lucene.analysis.TokenStream#DEFAULT_TOKEN_ATTRIBUTE_FACTORY

The following examples show how to use org.apache.lucene.analysis.TokenStream#DEFAULT_TOKEN_ATTRIBUTE_FACTORY . 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: NaturalSortKeyAttributeFactory.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 4 votes vote down vote up
public NaturalSortKeyAttributeFactory(Collator collator, int digits, int maxTokens) {
    this(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, collator, digits, maxTokens);
}
 
Example 3
Source File: WhitespaceTokenizerFactory.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Tokenizer create() {
    return new WhitespaceTokenizer(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, maxTokenLength);
}
 
Example 4
Source File: TestConcatenatingTokenStream.java    From lucene-solr with Apache License 2.0 3 votes vote down vote up
public void testInconsistentAttributeFactories() throws IOException {

    final MockTokenizer first = new MockTokenizer(AttributeFactory.DEFAULT_ATTRIBUTE_FACTORY, MockTokenizer.WHITESPACE, true);
    final MockTokenizer second = new MockTokenizer(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, MockTokenizer.WHITESPACE, true);

    expectThrows(IllegalArgumentException.class, () -> new ConcatenatingTokenStream(first, second));

  }
 
Example 5
Source File: ICUCollationAttributeFactory.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Create an ICUCollationAttributeFactory, using 
 * {@link TokenStream#DEFAULT_TOKEN_ATTRIBUTE_FACTORY} as the
 * factory for all other attributes.
 * @param collator CollationKey generator
 */
public ICUCollationAttributeFactory(Collator collator) {
  this(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, collator);
}
 
Example 6
Source File: WhitespaceTokenizer.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Construct a new WhitespaceTokenizer using a given max token length
 *
 * @param maxTokenLen maximum token length the tokenizer will emit.
 *        Must be greater than 0 and less than MAX_TOKEN_LENGTH_LIMIT (1024*1024)
 * @throws IllegalArgumentException if maxTokenLen is invalid.
 */
public WhitespaceTokenizer(int maxTokenLen) {
  super(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, maxTokenLen);
}
 
Example 7
Source File: CollationAttributeFactory.java    From lucene-solr with Apache License 2.0 2 votes vote down vote up
/**
 * Create a CollationAttributeFactory, using 
 * {@link TokenStream#DEFAULT_TOKEN_ATTRIBUTE_FACTORY} as the
 * factory for all other attributes.
 * @param collator CollationKey generator
 */
public CollationAttributeFactory(Collator collator) {
  this(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, collator);
}
 
Example 8
Source File: IcuCollationAttributeFactory.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Create an ICUCollationAttributeFactory, using
 * {@link TokenStream#DEFAULT_TOKEN_ATTRIBUTE_FACTORY} as the
 * factory for all other attributes.
 * @param collator CollationKey generator
 */
public IcuCollationAttributeFactory(Collator collator) {
    this(TokenStream.DEFAULT_TOKEN_ATTRIBUTE_FACTORY, collator);
}