Package org.apache.lucene.analysis

Examples of org.apache.lucene.analysis.StopAnalyzer


  }

  public void testStopwords() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(
        new StopAnalyzer(new String[] { "the", "foo" }));

    Query result = qp.parse("a:the OR a:foo", "a");
    assertNotNull("result is null and it shouldn't be", result);
    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: "
View Full Code Here


    boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
    StopFilter.setEnablePositionIncrementsDefault(true);
    try {
      StandardQueryParser qp = new StandardQueryParser();
      qp.setAnalyzer(
          new StopAnalyzer(new String[] { "the", "in", "are", "this" }));

      qp.setEnablePositionIncrements(true);

      String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
      // 0 2 5 7 8
View Full Code Here

//    Set stopWords = null;
    Set stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
   
    Analyzer[] analyzers = new Analyzer[] {
        new SimpleAnalyzer(),
        new StopAnalyzer(Version.LUCENE_CURRENT),
        new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
//        new WhitespaceAnalyzer(),
//        new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null),
//        new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, true, stopWords),       
//        new SnowballAnalyzer("English", StopAnalyzer.ENGLISH_STOP_WORDS),
View Full Code Here

  }
 
  // LUCENE-1448
  public void testEndOffsetPositionStopFilter() throws Exception {
    MockRAMDirectory dir = new MockRAMDirectory();
    IndexWriter w = new IndexWriter(dir, new StopAnalyzer(Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    Field f = new Field("field", "abcd the", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
    doc.add(f);
    doc.add(f);
    w.addDocument(doc);
View Full Code Here

      log.debug("Indexer.addFromIndex()" + m.getID());
      IndexWriter writer = null;
      try {

        if (IndexReader.indexExists(PATH)) {
          writer = new IndexWriter(new File(PATH), new StopAnalyzer(), false);
        } else {
          writer = new IndexWriter(new File(PATH), new StopAnalyzer(), true);
        }
        writer.addDocument(MessageDocument.getDocument(m));

      } catch (Exception e) {
        log.error("addToIndex", e);
View Full Code Here

  public static void flush(Authorization auth) throws UnauthorizedException{
    ForumFactory forumFactory = ForumFactory.getInstance(auth);
    if(! forumFactory.getPermissions(auth).get(Constants.SYSTEM_ADMIN)) throw new UnauthorizedException();
    try {
      IndexWriter writer = new IndexWriter(new File(PATH), new StopAnalyzer(), true);
      writer.close();
    } catch (IOException e) {
      log.error("impossible de flusher l'index ", e);
    }
  }
View Full Code Here

   * Return a random analyzer (Simple, Stop, Standard) to analyze the terms.
   */
  private Analyzer randomAnalyzer() {
    switch(random.nextInt(3)) {
      case 0: return new SimpleAnalyzer();
      case 1: return new StopAnalyzer(Version.LUCENE_CURRENT);
      default: return new StandardAnalyzer(Version.LUCENE_CURRENT);
    }
  }
View Full Code Here

  }
 
  // LUCENE-1448
  public void testEndOffsetPositionStopFilter() throws Exception {
    MockRAMDirectory dir = new MockRAMDirectory();
    IndexWriter w = new IndexWriter(dir, new StopAnalyzer(Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
    Document doc = new Document();
    Field f = new Field("field", "abcd the", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
    doc.add(f);
    doc.add(f);
    w.addDocument(doc);
View Full Code Here

    private final StopAnalyzer stopAnalyzer;

    @Inject public StopAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) {
        super(index, indexSettings, name, settings);
        Set<?> stopWords = Analysis.parseStopWords(env, settings, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
        this.stopAnalyzer = new StopAnalyzer(version, stopWords);
    }
View Full Code Here

  }

  public void testStopwords() throws Exception {
    StandardQueryParser qp = new StandardQueryParser();
    qp.setAnalyzer(
        new StopAnalyzer(TEST_VERSION_CURRENT, StopFilter.makeStopSet(TEST_VERSION_CURRENT, "the", "foo" )));

    Query result = qp.parse("a:the OR a:foo", "a");
    assertNotNull("result is null and it shouldn't be", result);
    assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
    assertTrue(((BooleanQuery) result).clauses().size() + " does not equal: "
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.StopAnalyzer

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.