private void doSpell(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); final Set<String> errors = new HashSet<String>(); checker.addSpellCheckListener(new SpellCheckListener() { public void spellingError(SpellCheckEvent event) { errors.add(event.getInvalidWord()); } }); JSONArray words = paramArray.optJSONArray(1); checker.checkSpelling(new StringWordTokenizer(words.toString())); respond(errors.iterator(), cmd, id); }
@SuppressWarnings("unchecked") private void doSuggest(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); String word = paramArray.optString(1); List<String> suggestions = checker.getSuggestions(word, 2); respond(suggestions.iterator(), cmd, id); }
/** * Constructs the SpellChecker. The default threshold is used * * @param dictionary The dictionary used for looking up words. */ public SpellChecker(SpellDictionary dictionary) { this(); addDictionary(dictionary); }
public SpellCheck(String dictFile) { super(); SpellDictionary dictionary = null; try { dictionary = new SpellDictionaryHashMap(new File(dictFile), null); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } spellChecker = new SpellChecker(dictionary); spellChecker.addSpellCheckListener(this); _correctionType = SpellCorrectionType.Add; }
public String spellCorrect(String text) { StringWordTokenizer swt = new StringWordTokenizer(text); spellChecker.checkSpelling(swt); return swt.getContext(); }
/** * Checks the text string. * <p> * Returns the corrected string. * * @param text The text that need to be spelled checked * @return The text after spell checking * @deprecated use checkSpelling(WordTokenizer) */ public String checkString(String text) { StringWordTokenizer tokens = new StringWordTokenizer(text); checkSpelling(tokens); return tokens.getContext(); }
private void doSpell(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); final Set<String> errors = new HashSet<String>(); checker.addSpellCheckListener(new SpellCheckListener() { public void spellingError(SpellCheckEvent event) { errors.add(event.getInvalidWord()); } }); JSONArray words = paramArray.optJSONArray(1); checker.checkSpelling(new StringWordTokenizer(words.toString())); respond(errors.iterator(), cmd, id); }
@SuppressWarnings("unchecked") private void doSuggest(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); String word = paramArray.optString(1); List<String> suggestions = checker.getSuggestions(word, 2); respond(suggestions.iterator(), cmd, id); }
private void doSpell(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); final Set<String> errors = new HashSet<String>(); checker.addSpellCheckListener(new SpellCheckListener() { public void spellingError(SpellCheckEvent event) { errors.add(event.getInvalidWord()); } }); JSONArray words = paramArray.optJSONArray(1); checker.checkSpelling(new StringWordTokenizer(words.toString())); respond(errors.iterator(), cmd, id); }
@SuppressWarnings("unchecked") private void doSuggest(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); String word = paramArray.optString(1); List<String> suggestions = checker.getSuggestions(word, 2); respond(suggestions.iterator(), cmd, id); }
private void doSpell(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); final Set<String> errors = new HashSet<>(); checker.addSpellCheckListener(new SpellCheckListener() { @Override public void spellingError(SpellCheckEvent event) { errors.add(event.getInvalidWord()); } }); JSONArray words = paramArray.optJSONArray(1); checker.checkSpelling(new StringWordTokenizer(words.toString())); respond(errors.iterator(), cmd, id); }
@SuppressWarnings("unchecked") private void doSuggest(final String cmd, final String id, final JSONArray paramArray) { final SpellChecker checker = new SpellChecker(dict); String word = paramArray.optString(1); List<String> suggestions = checker.getSuggestions(word, 2); respond(suggestions.iterator(), cmd, id); }
public void spellCheck(final JTextComponent jta) { final DefaultHighlighter dh = (DefaultHighlighter)jta.getHighlighter(); dh.removeAllHighlights(); com.swabunga.spell.event.SpellChecker sc = new com.swabunga.spell.event.SpellChecker(dictionary); sc.addSpellCheckListener(new SpellCheckListener() { @Override public void spellingError(SpellCheckEvent arg0) { int pos = arg0.getWordContextPosition(); try { dh.addHighlight(pos,pos+arg0.getInvalidWord().length(),underline); } catch (BadLocationException e1) { e1.printStackTrace(); } } }); try { sc.checkSpelling(new StringWordTokenizer(jta.getText(0,jta.getDocument().getLength()))); } catch (BadLocationException e) { e.printStackTrace(); } }
try { final String word= jta.getText(h.getStartOffset(),h.getEndOffset()-h.getStartOffset()); com.swabunga.spell.event.SpellChecker sc = new com.swabunga.spell.event.SpellChecker(dictionary); List<Word> l = sc.getSuggestions(word,140); JPopupMenu jpm = new JPopupMenu(); for (final Word s : l ) {