Java Code Examples for org.apache.lucene.analysis.Analyzer.TokenStreamComponents

The following examples show how to use org.apache.lucene.analysis.Analyzer.TokenStreamComponents. These examples are extracted from open source projects. 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 Project: jstarcraft-nlp   Source File: LuceneTokenizer.java    License: Apache License 2.0 5 votes vote down vote up
public LuceneTokenizer(Analyzer analyzer) {
    try (LuceneAdapter lucene = new LuceneAdapter(analyzer)) {
        TokenStreamComponents component = lucene.createComponents("text");
        this.reader = component.getSource();
        this.stream = component.getTokenStream();
    }
}
 
Example 2
Source Project: database   Source File: PatternAnalyzerImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected TokenStreamComponents createComponents(final String field) {
	//Use default grouping
	final Tokenizer tokenizer = new PatternTokenizer(pattern,-1);
	final TokenStream filter = new LowerCaseFilter(tokenizer);
	return new TokenStreamComponents(tokenizer, filter);
}
 
Example 3
Source Project: SciGraph   Source File: EntityAnalyzer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected TokenStreamComponents createComponents(String fieldName) {
  Tokenizer tokenizer = new WhitespaceTokenizer();
  TokenStream result =
      new PatternReplaceFilter(tokenizer,
          Pattern.compile("^([\\.!\\?,:;\"'\\(\\)]*)(.*?)([\\.!\\?,:;\"'\\(\\)]*)$"), "$2", true);
  result = new PatternReplaceFilter(result, Pattern.compile("'s"), "s", true);
  return new TokenStreamComponents(tokenizer, result);
}
 
Example 4
Source Project: Pydev   Source File: IndexingTest.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();

    // Create it in-memory
    indexApi = new IndexApi(new RAMDirectory(), true);
    indexApi.registerTokenizer(IFields.PYTHON, CodeAnalyzer.createPythonStreamComponents());
    TokenStreamComponents stringOrComment = CodeAnalyzer.createStringsOrCommentsStreamComponents();
    indexApi.registerTokenizer(IFields.STRING, stringOrComment);
    indexApi.registerTokenizer(IFields.COMMENT, stringOrComment);
}
 
Example 5
Source Project: Pydev   Source File: IndexApi.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void registerTokenizer(String fieldName, TokenStreamComponents tokenStream) {
    this.analyzer.registerTokenizer(fieldName, tokenStream);
}