Package com.swabunga.spell.event

Examples of com.swabunga.spell.event.SpellChecker


    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);
  }
View Full Code Here


    @RequestMapping(params="words", method = RequestMethod.POST)
    public ResponseEntity<String> checkWordList(@RequestParam("words") String words){

    JSONObject response = new JSONObject();

    SpellChecker spellChecker = new SpellChecker();
        Configuration cfg = spellChecker.getConfiguration();
        cfg.setBoolean(Configuration.SPELL_IGNOREUPPERCASE, false);
       
        Checker chk = new Checker();
        spellChecker.addSpellCheckListener(chk);
        for (SpellDictionary dictionary : dictionaries) {
            spellChecker.addDictionary(dictionary);
        }
   
        chk.init(response);
        spellChecker.checkSpelling(new StringWordTokenizer(words.trim()));   
           
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        return new ResponseEntity<String>(response.toString(), headers, HttpStatus.OK);
    }
View Full Code Here

    @RequestMapping(params="word", method = RequestMethod.POST)
    public ResponseEntity<String> suggestForWord(@RequestParam("word") String word){

    JSONObject response = new JSONObject();
   
    SpellChecker spellChecker = new SpellChecker();
        Configuration cfg = spellChecker.getConfiguration();
        cfg.setBoolean(Configuration.SPELL_IGNOREUPPERCASE, false);
       
        Suggester sug = new Suggester();
        spellChecker.addSpellCheckListener(sug);
        for (SpellDictionary dictionary : dictionaries) {
            spellChecker.addDictionary(dictionary);
        }
   
        sug.init(response);
        spellChecker.checkSpelling(new StringWordTokenizer(word));     
           
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        return new ResponseEntity<String>(response.toString(), headers, HttpStatus.OK);
    }
View Full Code Here

TOP

Related Classes of com.swabunga.spell.event.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.