Package org.apache.lucene.search.spell

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


                boolean setSuggestionQuery=false;
                while(it.hasNext()) {
                  id=(String) it.next();
                  // add to set to remove duplicate values
                  SuggestionItem si;
                  SpellChecker sc = getSpellChecker(id);
                  for(int i=0;i<strLiterals.length;i++) {
                    String[] arr = sc.suggestSimilar(strLiterals[i], 1000);
                    if(arr.length>0){
                      literals[i].set("<suggestion>"+arr[0]+"</suggestion>");
                      setSuggestionQuery=true;
                     
                      si=(SuggestionItem) suggestions.get(strLiterals[i]);
View Full Code Here


       
    }
   
    private SpellChecker getSpellChecker(String id) throws IOException {
      FSDirectory siDir = FSDirectory.getDirectory(FileWrapper.toFile(_getSpellDirectory(id)));
        SpellChecker spellChecker = new SpellChecker(siDir);
        return spellChecker;
    }
View Full Code Here

         this.spellIndexDirectory = FSDirectory.getDirectory(path, new NativeFSLockFactory(path));
         if (IndexReader.indexExists(spellIndexDirectory))
         {
            this.lastRefresh = System.currentTimeMillis();
         }
         this.spellChecker = new SpellChecker(spellIndexDirectory);
         this.spellChecker.setAccuracy(0.55f);
         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

        spellCheckerCache = CacheBuilder.newBuilder().build(
                new CacheLoader<String, SpellChecker>() {
                    @Override
                    public SpellChecker load(String field) throws Exception {
                        SpellChecker spellChecker = new SpellChecker(ramDirectoryCache.get(field));
                        IndexWriterConfig indexWriterConfig = new IndexWriterConfig(Version.LUCENE_44, new WhitespaceAnalyzer(Version.LUCENE_44));
                        spellChecker.indexDictionary(dictCache.getUnchecked(field), indexWriterConfig, false);
                        return spellChecker;
                    }
                }
        );
View Full Code Here

            if (ramDirectory != null) {
                ramDirectory.close();
                ramDirectoryCache.invalidate(field);
            }

            SpellChecker spellChecker = spellCheckerCache.getIfPresent(field);
            if (spellChecker != null) {
                spellCheckerCache.refresh(field);
                try {
                    spellChecker.close();
                } catch (IOException e) {
                    logger.error("Could not close spellchecker in indexshard [{}] for field [{}]", e, indexShard, field);
                }
            }
View Full Code Here

            dictCache.refresh(field);
        }

        try {
            for (String field : spellCheckerCache.asMap().keySet()) {
                SpellChecker oldSpellchecker = spellCheckerCache.getUnchecked(field);
                RAMDirectory oldRamDirectory = ramDirectoryCache.getUnchecked(field);
                ramDirectoryCache.refresh(field);
                spellCheckerCache.refresh(field);
                oldRamDirectory.close();
                oldSpellchecker.close();
            }
        } catch (IOException e ) {
            logger.error("Error refreshing spell checker cache [{}]", e, shardId);
        }
View Full Code Here

    if (_spellChecker == null) {
      String spellIndexDirectory = ERXProperties.stringForKey("er.examples.textsearchdemo.spellCheckIndexPath");
      File spellingDir = new File(spellIndexDirectory);
      try {
        Directory spellingDirectory = FSDirectory.open(spellingDir);
        _spellChecker = new SpellChecker(spellingDirectory);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return _spellChecker;
View Full Code Here

    if (_spellChecker == null) {
      String spellIndexDirectory = ERXProperties.stringForKey("er.examples.textsearchdemo.didYouMeanIndexPath");
      File spellingDir = new File(spellIndexDirectory);
      try {
        Directory spellingDirectory = FSDirectory.open(spellingDir);
        _spellChecker = new SpellChecker(spellingDirectory);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return _spellChecker;
View Full Code Here

         this.spellIndexDirectory = FSDirectory.getDirectory(path, new NativeFSLockFactory(path));
         if (IndexReader.indexExists(spellIndexDirectory))
         {
            this.lastRefresh = System.currentTimeMillis();
         }
         this.spellChecker = new SpellChecker(spellIndexDirectory);
         this.spellChecker.setAccuracy(0.55f);
         refreshSpellChecker();
      }
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.