Search in sources :

Example 26 with StopFilter

use of org.apache.lucene.analysis.StopFilter in project elasticsearch by elastic.

the class SnowballAnalyzer method createComponents.

/** Constructs a {@link StandardTokenizer} filtered by a {@link
      StandardFilter}, a {@link LowerCaseFilter}, a {@link StopFilter},
      and a {@link SnowballFilter} */
@Override
public TokenStreamComponents createComponents(String fieldName) {
    final Tokenizer tokenizer = new StandardTokenizer();
    TokenStream result = tokenizer;
    // remove the possessive 's for english stemmers
    if (name.equals("English") || name.equals("Porter") || name.equals("Lovins"))
        result = new EnglishPossessiveFilter(result);
    // Use a special lowercase filter for turkish, the stemmer expects it.
    if (name.equals("Turkish"))
        result = new TurkishLowerCaseFilter(result);
    else
        result = new LowerCaseFilter(result);
    if (stopSet != null)
        result = new StopFilter(result, stopSet);
    result = new SnowballFilter(result, name);
    return new TokenStreamComponents(tokenizer, result);
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) EnglishPossessiveFilter(org.apache.lucene.analysis.en.EnglishPossessiveFilter) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) StopFilter(org.apache.lucene.analysis.StopFilter) TurkishLowerCaseFilter(org.apache.lucene.analysis.tr.TurkishLowerCaseFilter) SnowballFilter(org.apache.lucene.analysis.snowball.SnowballFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter) TurkishLowerCaseFilter(org.apache.lucene.analysis.tr.TurkishLowerCaseFilter)

Example 27 with StopFilter

use of org.apache.lucene.analysis.StopFilter in project elasticsearch by elastic.

the class StandardHtmlStripAnalyzer method createComponents.

@Override
protected TokenStreamComponents createComponents(final String fieldName) {
    final Tokenizer src = new StandardTokenizer();
    TokenStream tok = new StandardFilter(src);
    tok = new LowerCaseFilter(tok);
    if (!stopwords.isEmpty()) {
        tok = new StopFilter(tok, stopwords);
    }
    return new TokenStreamComponents(src, tok);
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) StopFilter(org.apache.lucene.analysis.StopFilter) StandardFilter(org.apache.lucene.analysis.standard.StandardFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter)

Example 28 with StopFilter

use of org.apache.lucene.analysis.StopFilter in project elasticsearch by elastic.

the class FingerprintAnalyzer method createComponents.

@Override
protected TokenStreamComponents createComponents(String s) {
    final Tokenizer tokenizer = new StandardTokenizer();
    TokenStream stream = tokenizer;
    stream = new LowerCaseFilter(stream);
    stream = new ASCIIFoldingFilter(stream, false);
    stream = new StopFilter(stream, stopWords);
    stream = new FingerprintFilter(stream, maxOutputSize, separator);
    return new TokenStreamComponents(tokenizer, stream);
}
Also used : FingerprintFilter(org.apache.lucene.analysis.miscellaneous.FingerprintFilter) TokenStream(org.apache.lucene.analysis.TokenStream) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) StopFilter(org.apache.lucene.analysis.StopFilter) ASCIIFoldingFilter(org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter)

Example 29 with StopFilter

use of org.apache.lucene.analysis.StopFilter in project zm-mailbox by Zimbra.

the class UniversalAnalyzer method createTokenStream.

private TokenStream createTokenStream(Tokenizer tokenizer) {
    TokenStream result = new UniversalTokenFilter(tokenizer);
    Set stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
    try {
        stopWords = Provisioning.getInstance().getConfig().getMultiAttrSet(Provisioning.A_zimbraDefaultAnalyzerStopWords);
    } catch (ServiceException e) {
        ZimbraLog.index.error("Failed to retrieve stop words from LDAP", e);
    }
    // disable position increment for backward compatibility
    result = new StopFilter(LuceneIndex.VERSION, result, stopWords);
    return result;
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) Set(java.util.Set) ServiceException(com.zimbra.common.service.ServiceException) StopFilter(org.apache.lucene.analysis.StopFilter)

Example 30 with StopFilter

use of org.apache.lucene.analysis.StopFilter in project lucene-solr by apache.

the class SoraniAnalyzer method createComponents.

/**
   * Creates a
   * {@link org.apache.lucene.analysis.Analyzer.TokenStreamComponents}
   * which tokenizes all the text in the provided {@link Reader}.
   * 
   * @return A
   *         {@link org.apache.lucene.analysis.Analyzer.TokenStreamComponents}
   *         built from an {@link StandardTokenizer} filtered with
   *         {@link StandardFilter}, {@link SoraniNormalizationFilter}, 
   *         {@link LowerCaseFilter}, {@link DecimalDigitFilter}, {@link StopFilter}
   *         , {@link SetKeywordMarkerFilter} if a stem exclusion set is
   *         provided and {@link SoraniStemFilter}.
   */
@Override
protected TokenStreamComponents createComponents(String fieldName) {
    final Tokenizer source = new StandardTokenizer();
    TokenStream result = new StandardFilter(source);
    result = new SoraniNormalizationFilter(result);
    result = new LowerCaseFilter(result);
    result = new DecimalDigitFilter(result);
    result = new StopFilter(result, stopwords);
    if (!stemExclusionSet.isEmpty())
        result = new SetKeywordMarkerFilter(result, stemExclusionSet);
    result = new SoraniStemFilter(result);
    return new TokenStreamComponents(source, result);
}
Also used : DecimalDigitFilter(org.apache.lucene.analysis.core.DecimalDigitFilter) TokenStream(org.apache.lucene.analysis.TokenStream) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) StopFilter(org.apache.lucene.analysis.StopFilter) SetKeywordMarkerFilter(org.apache.lucene.analysis.miscellaneous.SetKeywordMarkerFilter) StandardFilter(org.apache.lucene.analysis.standard.StandardFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter)

Aggregations

StopFilter (org.apache.lucene.analysis.StopFilter)59 TokenStream (org.apache.lucene.analysis.TokenStream)49 Tokenizer (org.apache.lucene.analysis.Tokenizer)47 LowerCaseFilter (org.apache.lucene.analysis.LowerCaseFilter)42 StandardTokenizer (org.apache.lucene.analysis.standard.StandardTokenizer)38 StandardFilter (org.apache.lucene.analysis.standard.StandardFilter)35 SetKeywordMarkerFilter (org.apache.lucene.analysis.miscellaneous.SetKeywordMarkerFilter)31 SnowballFilter (org.apache.lucene.analysis.snowball.SnowballFilter)15 CharArraySet (org.apache.lucene.analysis.CharArraySet)7 Analyzer (org.apache.lucene.analysis.Analyzer)6 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)5 DecimalDigitFilter (org.apache.lucene.analysis.core.DecimalDigitFilter)5 MockAnalyzer (org.apache.lucene.analysis.MockAnalyzer)4 ElisionFilter (org.apache.lucene.analysis.util.ElisionFilter)4 Reader (java.io.Reader)3 KeywordTokenizer (org.apache.lucene.analysis.core.KeywordTokenizer)3 Input (org.apache.lucene.search.suggest.Input)3 InputArrayIterator (org.apache.lucene.search.suggest.InputArrayIterator)3 TokenFilter (org.apache.lucene.analysis.TokenFilter)2 StandardAnalyzer (org.apache.lucene.analysis.standard.StandardAnalyzer)2