/** * gets a new default Configuration * @return Configuration */ public static final Configuration getConfiguration() { try { String config = System.getProperty("jazzy.config"); // added by bd if (config != null && config.length() > 0) return getConfiguration(config); } catch (AccessControlException e) { e.printStackTrace(); } return getConfiguration(null); }
/** * Constructs the SpellChecker with a threshold * * @param dictionary the dictionary used for looking up words. * @param threshold the cost value above which any suggestions are * thrown away */ public SpellChecker(SpellDictionary dictionary, int threshold) { this(dictionary); config.setInteger(Configuration.SPELL_THRESHOLD, threshold); }
private Vector getWordsFromCode(String word, Hashtable codes) { Configuration config = Configuration.getConfiguration(); Vector result = new Vector(); int[][] matrix = new int[0][0]; final int configDistance = config.getInteger(Configuration.SPELL_THRESHOLD); for (Enumeration i = codes.keys(); i.hasMoreElements();) { String code = (String) i.nextElement(); List simwordlist = getWords(code); for (Iterator iter = simwordlist.iterator(); iter.hasNext();) { String similar = (String) iter.next(); int distance = EditDistance.getDistance(word, similar, matrix); if (distance < configDistance) { Word w = new Word(similar, distance); result.addElement(w); } } } return result; }
private boolean isSupposedToBeCapitalized(String word, WordTokenizer wordTokenizer) { boolean configCapitalize = !config.getBoolean(Configuration.SPELL_IGNORESENTENCECAPITALIZATION); return configCapitalize && wordTokenizer.isNewSentence() && Character.isLowerCase(word.charAt(0)); }
public static final Configuration config = Configuration.getConfiguration(); static final int costOfDeletingSourceCharacter = config.getInteger(Configuration.COST_REMOVE_CHAR); static final int costOfInsertingSourceCharacter = config.getInteger(Configuration.COST_INSERT_CHAR); static final int costOfSubstitutingLetters = config.getInteger(Configuration.COST_SUBST_CHARS); static final int costOfSwappingLetters = config.getInteger(Configuration.COST_SWAP_CHARS); static final int costOfChangingCase = config.getInteger(Configuration.COST_CHANGE_CASE);
if ((config.getBoolean(Configuration.SPELL_IGNOREMIXEDCASE) && isMixedCaseWord(word, tokenizer.isNewSentence())) || (config.getBoolean(Configuration.SPELL_IGNOREUPPERCASE) && isUpperCaseWord(word)) || (config.getBoolean(Configuration.SPELL_IGNORESINGLELETTERS) && word.length()==1) || (config.getBoolean(Configuration.SPELL_IGNOREDIGITWORDS) && isDigitWord(word)) || (config.getBoolean(Configuration.SPELL_IGNOREINTERNETADDRESSES) && isINETWord(word))) {