/** * Constructs the SpellChecker. */ public SpellChecker() { try { userdictionary = new SpellDictionaryHashMap(); } catch (IOException e) { throw new RuntimeException("this exception should never happen because we are using null phonetic file"); } }
/** * Construct spell checker resource. */ public JazzySpellChecker() { // todo load dict file from jazzy.jar archive. InputStream inputStream = getClass().getClassLoader().getResourceAsStream(dictFile); InputStreamReader reader = new InputStreamReader(inputStream); try { dict = new SpellDictionaryHashMap(reader); } catch (IOException e) { throw new RuntimeException(e); } finally { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } } resourceStream = new StringBufferResourceStream(contentType); }
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; }
/** * Construct spell checker resource. */ public JazzySpellChecker() { // todo load dict file from jazzy.jar archive. InputStream inputStream = getClass().getClassLoader().getResourceAsStream(dictFile); InputStreamReader reader = new InputStreamReader(inputStream); try { dict = new SpellDictionaryHashMap(reader); } catch (IOException e) { throw new RuntimeException(e); } finally { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } } resourceStream = new StringBufferResourceStream(contentType); }
/** * Construct spell checker resource. */ public JazzySpellChecker() { // todo load dict file from jazzy.jar archive. InputStream inputStream = getClass().getClassLoader().getResourceAsStream(dictFile); InputStreamReader reader = new InputStreamReader(inputStream); try { dict = new SpellDictionaryHashMap(reader); } catch (IOException e) { throw new RuntimeException(e); } finally { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } } resourceStream = new StringBufferResourceStream(contentType); }
/** * Construct spell checker resource. */ public JazzySpellChecker() { // todo load dict file from jazzy.jar archive. InputStream inputStream = getClass().getClassLoader().getResourceAsStream(dictFile); InputStreamReader reader = new InputStreamReader(inputStream); try { dict = new SpellDictionaryHashMap(reader); } catch (IOException e) { throw new RuntimeException(e); } finally { try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } } resourceStream = new StringBufferResourceStream(contentType); }
@Override public void initialize(final UimaContext context) throws ResourceInitializationException { super.initialize(context); InputStream is = null; try { URL url = ResourceUtils.resolveLocation(dictPath, this, context); this.getLogger().debug("Loading dictionary from " + url); is = url.openStream(); dict = new SpellDictionaryHashMap(new InputStreamReader(is, dictEncoding)); } catch (IOException e) { throw new ResourceInitializationException(e); } finally { closeQuietly(is); } }
@Override public void initialize(final UimaContext context) throws ResourceInitializationException { super.initialize(context); InputStream is = null; try { URL url = ResourceUtils.resolveLocation(dictPath, this, context); this.getLogger().debug("Loading dictionary from " + url); is = url.openStream(); dict = new SpellDictionaryHashMap(new InputStreamReader(is, dictEncoding)); } catch (IOException e) { throw new ResourceInitializationException(e); } finally { closeQuietly(is); } }