Search in sources :

Example 1 with ArabicNormalizationFilter

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

the class PersianAnalyzer method normalize.

@Override
protected TokenStream normalize(String fieldName, TokenStream in) {
    TokenStream result = new StandardFilter(in);
    result = new LowerCaseFilter(result);
    result = new DecimalDigitFilter(result);
    result = new ArabicNormalizationFilter(result);
    /* additional persian-specific normalization */
    result = new PersianNormalizationFilter(result);
    return result;
}
Also used : DecimalDigitFilter(org.apache.lucene.analysis.core.DecimalDigitFilter) ArabicNormalizationFilter(org.apache.lucene.analysis.ar.ArabicNormalizationFilter) TokenStream(org.apache.lucene.analysis.TokenStream) StandardFilter(org.apache.lucene.analysis.standard.StandardFilter) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter)

Example 2 with ArabicNormalizationFilter

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

the class PersianAnalyzer method createComponents.

/**
   * Creates
   * {@link org.apache.lucene.analysis.Analyzer.TokenStreamComponents}
   * used to tokenize all the text in the provided {@link Reader}.
   * 
   * @return {@link org.apache.lucene.analysis.Analyzer.TokenStreamComponents}
   *         built from a {@link StandardTokenizer} filtered with
   *         {@link LowerCaseFilter}, {@link DecimalDigitFilter}, {@link ArabicNormalizationFilter},
   *         {@link PersianNormalizationFilter} and Persian Stop words
   */
@Override
protected TokenStreamComponents createComponents(String fieldName) {
    final Tokenizer source = new StandardTokenizer();
    TokenStream result = new LowerCaseFilter(source);
    result = new DecimalDigitFilter(result);
    result = new ArabicNormalizationFilter(result);
    /* additional persian-specific normalization */
    result = new PersianNormalizationFilter(result);
    /*
     * the order here is important: the stopword list is normalized with the
     * above!
     */
    return new TokenStreamComponents(source, new StopFilter(result, stopwords));
}
Also used : DecimalDigitFilter(org.apache.lucene.analysis.core.DecimalDigitFilter) ArabicNormalizationFilter(org.apache.lucene.analysis.ar.ArabicNormalizationFilter) TokenStream(org.apache.lucene.analysis.TokenStream) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) StopFilter(org.apache.lucene.analysis.StopFilter) Tokenizer(org.apache.lucene.analysis.Tokenizer) StandardTokenizer(org.apache.lucene.analysis.standard.StandardTokenizer) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter)

Aggregations

LowerCaseFilter (org.apache.lucene.analysis.LowerCaseFilter)2 TokenStream (org.apache.lucene.analysis.TokenStream)2 ArabicNormalizationFilter (org.apache.lucene.analysis.ar.ArabicNormalizationFilter)2 DecimalDigitFilter (org.apache.lucene.analysis.core.DecimalDigitFilter)2 StopFilter (org.apache.lucene.analysis.StopFilter)1 Tokenizer (org.apache.lucene.analysis.Tokenizer)1 StandardFilter (org.apache.lucene.analysis.standard.StandardFilter)1 StandardTokenizer (org.apache.lucene.analysis.standard.StandardTokenizer)1