Java 类org.apache.lucene.analysis.snowball.SnowballAnalyzer 实例源码

项目:concourseconnect-community    文件:LuceneIndexer.java   
private void resetSearchers() throws IOException {
  // New analyzers and readers since there is new data
  Analyzer fullAnalyzer = new StandardAnalyzer();
  LuceneIndexerSearch newFullSearcher = new LuceneIndexerSearch();
  newFullSearcher.setup(fullIndex, fullAnalyzer, Constants.INDEXER_FULL);
  fullSearcher = newFullSearcher;

  // New analyzers and readers since there is new data
  Analyzer directoryAnalyzer = new SnowballAnalyzer("English");
  LuceneIndexerSearch newDirectorySearcher = new LuceneIndexerSearch();
  newDirectorySearcher.setup(directoryIndex, directoryAnalyzer, Constants.INDEXER_DIRECTORY);
  directorySearcher = newDirectorySearcher;
  if (directoryIndexInitialized) {
    directorySearcherReady = true;
  }
}
项目:concourseconnect-community    文件:LuceneIndexer.java   
/**
 * Sets up any Lucene Indexer classes
 *
 * @param context
 * @return
 * @throws Exception
 */
public boolean setup(IndexerContext context) throws Exception {
  // Make sure the complex queries can use more than the default clause count
  BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);

  // Setup the Indexes so they are in a state in which they can immediately
  // be accessed
  ApplicationPrefs prefs = context.getApplicationPrefs();
  {
    // Establish the full directory
    LOG.info("Starting Lucene disk index");
    File path = new File(prefs.get("FILELIBRARY") + Constants.FULL_INDEX);
    boolean create = !path.exists();
    fullIndex = FSDirectory.getDirectory(prefs.get("FILELIBRARY") + Constants.FULL_INDEX);
    if (create) {
      LOG.warn("Lucene index not found, creating new index: " + path.getPath());
      Analyzer fullAnalyzer = new StandardAnalyzer();
      fullWriter = new IndexWriter(fullIndex, fullAnalyzer, true);
      fullWriter.close();
    }
  }

  {
    // Load up the ram directory
    LOG.info("Creating Lucene RAM index...");
    // Create the Ram Directory
    directoryIndex = new RAMDirectory();
    Analyzer directoryAnalyzer = new SnowballAnalyzer("English");
    directoryWriter = new IndexWriter(directoryIndex, directoryAnalyzer, true);
    directoryWriter.close();
    LOG.info("Initialization of RAM index complete...");
  }
  // Search using the updated index
  resetSearchers();
  return true;
}
项目:concourseconnect-community    文件:AbstractLuceneTest.java   
protected void setUp() throws Exception {
  // Snowball
  snowballAnalyzer = new SnowballAnalyzer("English");
  snowballIndex = new RAMDirectory();
  snowballWriter = new IndexWriter(snowballIndex, snowballAnalyzer, true);
  // Standard
  standardAnalyzer = new StandardAnalyzer();
  standardIndex = new RAMDirectory();
  standardWriter = new IndexWriter(standardIndex, standardAnalyzer, true);
}
项目:Lucee4    文件:SpanishAnalyzer.java   
/**
 * Creates new instance of SpanishAnalyzer
 */
public SpanishAnalyzer() {
    analyzer = new SnowballAnalyzer("Spanish", SPANISH_STOP_WORDS);
}
项目:Lucee4    文件:SpanishAnalyzer.java   
public SpanishAnalyzer(String stopWords[]) {
    analyzer = new SnowballAnalyzer("Spanish", stopWords);
}
项目:Lucee4    文件:DanishAnalyzer.java   
/**
 * Creates new instance of SpanishAnalyzer
 */
public DanishAnalyzer() {
    analyzer = new SnowballAnalyzer("Danish", STOP_WORDS);
}
项目:Lucee4    文件:DanishAnalyzer.java   
public DanishAnalyzer(String stopWords[]) {
    analyzer = new SnowballAnalyzer("Danish", stopWords);
}
项目:Lucee4    文件:PortugueseAnalyzer.java   
/**
 * Creates new instance of SpanishAnalyzer
 */
public PortugueseAnalyzer() {
    analyzer = new SnowballAnalyzer("Portuguese", PORTUGUESE_STOP_WORDS);
}
项目:Lucee4    文件:PortugueseAnalyzer.java   
public PortugueseAnalyzer(String stopWords[]) {
    analyzer = new SnowballAnalyzer("Portuguese", stopWords);
}
项目:Lucee4    文件:ItalianAnalyzer.java   
/**
 * Creates new instance of SpanishAnalyzer
 */
public ItalianAnalyzer() {
    analyzer = new SnowballAnalyzer("Italian", STOP_WORDS);
}
项目:Lucee4    文件:ItalianAnalyzer.java   
public ItalianAnalyzer(String stopWords[]) {
    analyzer = new SnowballAnalyzer("Italian", stopWords);
}
项目:Lucee4    文件:NorwegianAnalyzer.java   
/**
 * Creates new instance of SpanishAnalyzer
 */
public NorwegianAnalyzer() {
    analyzer = new SnowballAnalyzer("Norwegian", NORWEGIAN_STOP_WORDS);
}
项目:Lucee4    文件:NorwegianAnalyzer.java   
public NorwegianAnalyzer(String stopWords[]) {
    analyzer = new SnowballAnalyzer("Norwegian", stopWords);
}
项目:concourseconnect-community    文件:LuceneIndexer.java   
public boolean reindexAllData(IndexerContext context, Connection db) throws Exception {
    writeLock.lock();
    try {
      if (context.getIndexType() == Constants.INDEXER_FULL) {
        // Erase the full index
        LOG.info("Reloading the full index...");
        fullWriter = new IndexWriter(fullIndex, new StandardAnalyzer(), true);
        // Reindex all data
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.profile.dao.ProjectIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.blog.dao.BlogPostIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.wiki.dao.WikiIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.discussion.dao.ForumIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.discussion.dao.TopicIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.discussion.dao.ReplyIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.documents.dao.FileItemIndexer")).add(this, db, context);
//        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.lists.dao.TaskCategoryIndexer")).add(this, db, context);
//        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.lists.dao.TaskIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.issues.dao.TicketIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.plans.dao.RequirementIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.plans.dao.AssignmentFolderIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.plans.dao.AssignmentIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.plans.dao.AssignmentNoteIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.promotions.dao.AdIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.classifieds.dao.ClassifiedIndexer")).add(this, db, context);
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.reviews.dao.ProjectRatingIndexer")).add(this, db, context);
        // Optimize the index
        fullWriter.flush();
        fullWriter.optimize();
        fullWriter.close();
        // Update the searchers
        resetSearchers();
        return true;
      } else if (context.getIndexType() == Constants.INDEXER_DIRECTORY) {
        // Erase the directory index
        LOG.info("Reloading the directory index...");
        directoryWriter = new IndexWriter(directoryIndex, new SnowballAnalyzer("English"), true);
        // Just the project data belongs in the directory index
        ((Indexer) getObjectIndexer("com.concursive.connect.web.modules.profile.dao.ProjectIndexer")).add(this, db, context);
        // Optimize the index
        directoryWriter.flush();
        directoryWriter.optimize();
        directoryWriter.close();
        // Update the searchers
        resetSearchers();
        return true;
      }
    } catch (Exception e) {
      LOG.error("Erase index error", e);
    } finally {
      writeLock.unlock();
    }
    return false;
  }
项目:t4f-data    文件:SnowballTest.java   
public void testEnglish() throws Exception {
  Analyzer analyzer = new SnowballAnalyzer(Version.LUCENE_41, "English");
  AnalyzerUtils.assertAnalyzesTo(analyzer,
                                 "stemming algorithms",
                                 new String[] {"stem", "algorithm"});
}
项目:t4f-data    文件:SnowballTest.java   
public void testSpanish() throws Exception {
  Analyzer analyzer = new SnowballAnalyzer(Version.LUCENE_41, "Spanish");
  AnalyzerUtils.assertAnalyzesTo(analyzer,
                                 "algoritmos",
                                 new String[] {"algoritm"});
}