Package com.dotcms.repackage.org.dts.spell

Examples of com.dotcms.repackage.org.dts.spell.SpellChecker


    protected void preloadLanguageChecker(String preloadedLanguage) throws SpellCheckException {
        getChecker(preloadedLanguage);
    }

    protected List<String> findMisspelledWords(Iterator<String> checkedWordsIterator, String lang) throws SpellCheckException {
        SpellChecker checker = (SpellChecker) getChecker(lang);

        List<String> misspelledWordsList = new ArrayList<String>();
        while (checkedWordsIterator.hasNext()) {
            String word = checkedWordsIterator.next();
            if (!word.equals("") && !checker.isCorrect(word) ) {
                misspelledWordsList.add(word);
            }
        }

        return misspelledWordsList;
View Full Code Here


        return misspelledWordsList;
    }

    protected List<String> findSuggestions(String word, String lang, int maxSuggestions) throws SpellCheckException {
        SpellChecker checker = (SpellChecker) getChecker(lang);
        return checker.getDictionary().getSuggestions(word, maxSuggestions);
    }
View Full Code Here

     * @return instance of jazzy SpellChecker
     * @throws SpellCheckException if method failed to load the SpellChecker for lang (it happens if there is no
     *                             dictionaries for that language was found in the classpath
     */
    protected Object getChecker(String lang) throws SpellCheckException {
        SpellChecker cachedCheker = spellcheckersCache.get(lang);

        /**
         * Even if the SpellChecker is present we need to validate if the dictionary is available for use,
         * and if not we should force a reloading of the SpellChecker for this language.
         *
         * On some scenarios the dictionary (WEB-INF/dictionary/jmyspell/en_US.zip, WEB-INF/dictionary/jmyspell/es_ES.zip, etc)
         * is not longer available even with the SpellChecker object alive causing a java.lang.IllegalStateException, that's why
         * a check on the dictionary and a reload is required.
         */
        Boolean forceReloading = false;
        if ( cachedCheker != null ) {
            if ( cachedCheker.getDictionary() == null || !cachedCheker.getDictionary().isLoad() ) {
                forceReloading = true;
            }
        }

        if ( cachedCheker == null || forceReloading ) {
View Full Code Here

        try {
            dict = new com.dotcms.repackage.org.dts.spell.dictionary.openoffice.OpenOfficeSpellDictionary(new ZipFile(dictionaryFile));
        } catch (IOException e) {
            throw new SpellCheckException("Failed to load dictionary for language" + lang, e);
        }
        SpellChecker checker = new SpellChecker(dict);
        configureSpellChecker(checker);
        return checker;
    }
View Full Code Here

        }catch(Exception e){
          Logger.warn(TinyMCESpellCheckerServlet.class, e.getMessage(), e);
        }
            lang = ("".equals(lang)) ? DEFAULT_LANGUAGE : lang;
            String word = params.getString("word");
        SpellChecker checker = (SpellChecker) getChecker(lang);
        checker.getDictionary().addWord(word);
        return "Word added successfully";
      }else{
        return "Word can't be added in the dictionary";
      }
    }
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.dts.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.