Package org.apache.lucene.search.spell

Examples of org.apache.lucene.search.spell.SpellChecker


                  lastRefresh = System.currentTimeMillis();
               }
               return null;
            }
         });
         this.spellChecker = new SpellChecker(spellIndexDirectory);
         this.spellChecker.setAccuracy(minDistance);
         this.morePopular = morePopular;
         refreshSpellChecker();
      }
View Full Code Here


                  lastRefresh = System.currentTimeMillis();
               }
               return null;
            }
         });
         this.spellChecker = new SpellChecker(spellIndexDirectory);
         this.spellChecker.setAccuracy(minDistance);
         this.morePopular = morePopular;
         refreshSpellChecker();
      }
View Full Code Here

                  lastRefresh = System.currentTimeMillis();
               }
               return null;
            }
         });
         this.spellChecker = new SpellChecker(spellIndexDirectory);
         this.spellChecker.setAccuracy(minDistance);
         this.morePopular = morePopular;
         refreshSpellChecker();
      }
View Full Code Here

        log.info("using spell directory: " + dirDescription);
        spellcheckerIndexDir = FSDirectory.getDirectory(f);
      } else {
        log.info("using RAM based spell directory");
      }
      spellChecker = new SpellChecker(spellcheckerIndexDir);
    } catch (IOException e) {
      throw new RuntimeException("Cannot open SpellChecker index", e);
    }
  }
View Full Code Here

        List<String> dummy = new ArrayList<>();
        for (File aSpellIndex : spellIndex) {
            if (!aSpellIndex.exists()) {
                continue;
            }
            SpellChecker checker = null;
            Suggestion s = new Suggestion(aSpellIndex.getName());
            try (FSDirectory spellDirectory = FSDirectory.open(aSpellIndex)) {
                checker = new SpellChecker(spellDirectory);
                getSuggestion(builder.getFreetext(), checker, dummy);
                s.freetext = dummy.toArray(new String[dummy.size()]);
                dummy.clear();
                getSuggestion(builder.getRefs(), checker, dummy);
                s.refs = dummy.toArray(new String[dummy.size()]);
                dummy.clear();
                // TODO it seems the only true spellchecker is for
                // below field, see IndexDatabase
                // createspellingsuggestions ...
                getSuggestion(builder.getDefs(), checker, dummy);
                s.defs = dummy.toArray(new String[dummy.size()]);
                dummy.clear();
                if (s.freetext.length > 0 || s.defs.length > 0 || s.refs.length > 0) {
                    res.add(s);
                }
            } catch (IOException e) {
                log.log(Level.WARNING, "Got excption while getting spelling suggestions: ", e);
            } finally {
                if (checker != null) {
                    try {
                        checker.close();
                    } catch (Exception x) {
                        log.log(Level.WARNING, "Got excption while closing spelling suggestions: ", x);
                    }
                }
            }
View Full Code Here

    /**
     * Generate a spelling suggestion for the definitions stored in defs
     */
    public void createSpellingSuggestions() {
        IndexReader indexReader = null;
        SpellChecker checker = null;

        try {
            log.info("Generating spelling suggestion index ... ");
            indexReader = IndexReader.open(indexDirectory);
            checker = new SpellChecker(spellDirectory);
            //TODO below seems only to index "defs" , possible bug ?
            checker.indexDictionary(new LuceneDictionary(indexReader, "defs"), new IndexWriterConfig(Version.LUCENE_36, null), true);
            log.info("done");
        } catch (IOException e) {
            log.log(Level.SEVERE, "ERROR: Generating spelling: {0}", e);
        } finally {
            if (indexReader != null) {
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.spell.SpellChecker

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.