Package org.apache.lucene.analysis.shingle

Examples of org.apache.lucene.analysis.shingle.ShingleAnalyzerWrapper


    private static final int MAX_WORDS_IN_SHINGLE = 2;
   
    private Analyzer _analyzer;

    public PhraseShingleAnalyzer(int maxWordsInShingle) {
        _analyzer = new ShingleAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_42), maxWordsInShingle);
    }
View Full Code Here


    Analyzer analyzer //<co id="mlt.analyzersetup"/>
      = new EnglishAnalyzer(Version.LUCENE_36);
   
    if (nGramSize > 1) { //<co id="mlt.ngramsetup"/>
      analyzer = new ShingleAnalyzerWrapper(analyzer, nGramSize,
              nGramSize);
    }
   
    MoreLikeThis moreLikeThis  = new MoreLikeThis(indexReader); //<co id="mlt.configure"/>
    moreLikeThis.setAnalyzer(analyzer);
View Full Code Here

 
  public void setNgramSize(int size) {
    if (size <= 1) return;
   
    Analyzer a = moreLikeThis.getAnalyzer();
    ShingleAnalyzerWrapper sw;
    if (a instanceof ShingleAnalyzerWrapper) {
      sw = (ShingleAnalyzerWrapper) a;
    }
    else {
      sw = new ShingleAnalyzerWrapper(a);
      moreLikeThis.setAnalyzer(sw);
    }
   
    sw.setMaxShingleSize(size);
    sw.setMinShingleSize(size);
  }
View Full Code Here

      = FSDirectory.open(new File(pathname));
    Analyzer analyzer   //<co id="luc.index.analyzer"/>
      = new EnglishAnalyzer(Version.LUCENE_36);
   
    if (nGramSize > 1) { //<co id="luc.index.shingle"/>
      ShingleAnalyzerWrapper sw
        = new ShingleAnalyzerWrapper(analyzer,
            nGramSize, // min shingle size
            nGramSize, // max shingle size
            "-",       // token separator
            true,      // output unigrams
            true);     // output unigrams if no shingles
View Full Code Here

    } catch (NoSuchMethodException e) {
      // otherwise use default ctor
      wrappedAnalyzer = clazz.newInstance();
    }
   
    ShingleAnalyzerWrapper analyzer = new ShingleAnalyzerWrapper(
        wrappedAnalyzer,
        ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE,
        maxShingleSize,
        ShingleFilter.TOKEN_SEPARATOR,
        outputUnigrams,
View Full Code Here

      wrappedAnalyzer = ctor.newInstance(Version.LUCENE_CURRENT);
    } catch (NoSuchMethodException e) {
      // otherwise use default ctor
      wrappedAnalyzer = clazz.newInstance();
    }
    ShingleAnalyzerWrapper analyzer
      = new ShingleAnalyzerWrapper(wrappedAnalyzer, maxShingleSize);
    analyzer.setOutputUnigrams(outputUnigrams);
    getRunData().setAnalyzer(analyzer);
  }
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.shingle.ShingleAnalyzerWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.