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; }
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); }
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); }
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); }
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(); } }
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); }