SpellChecker
SpellChecker copied to clipboard
english.zip file has access issues when using default static SpellingParser createEnglishSpellingParser() method :
i have updated to fix location of english.zip to a directory inside the ui resources package so user only need to put .dic files and and choose american/ programming so direct include spell checks inside the text editors by calling static method and passing 2 boolean values instead of using zip file. if this could enhance the usability then i could send a pull request for review.
sample refactored method working correct :100:
public static SpellingParser createEnglishSpellingParser(boolean american, boolean programming) throws IOException {
SpellDictionaryHashMap dict;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(SpellingParser.class.getClassLoader().getResourceAsStream("org/fife/english_dic/eng_com.dic"))))) {
dict = new SpellDictionaryHashMap(reader);
}
List<String> others;
if (american) {
others = new ArrayList<>(Arrays.asList("color", "labeled", "center", "ize", "yze"));
} else {
others = new ArrayList<>(Arrays.asList("colour", "labelled", "centre", "ise", "yse"));
}
if (programming) {
others.add("programming");
}
for (String other : others) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
Objects.requireNonNull(SpellingParser.class.getClassLoader().getResourceAsStream("org/fife/english_dic/" + other + ".dic"))))) {
dict.addDictionary(reader);
// System.out.println("Added " + other); } }
return new SpellingParser(dict);
}