Following on from from a previous post, how to add ignored words, I want to add new words after adding the new rule:
langTool.disableRule("MORFOLOGIK_RULE_EN_GB");
MorfologikSpellerRule spellingRule = new MorfologikSpellerRule(
JLanguageTool.getMessageBundle(), language) {
@Override
public String getFileName() {
return "/en/hunspell/en_GB.dict";
}
@Override
public String getId() {
return "NEW_SPELLING_RULE";
}
};
// list of words to be ignored
spellingRule.addIgnoreTokens(ignored);
langTool.addRule(spellingRule);
It seems the only way I can add more ignored words is to get the “NEW_SPELLING_RULE” by looping all the rules:
for (Rule rule : langTool.getAllRules()) {
if (rule.getId().equals("NEW_SPELLING_RULE")) {
((MorfologikSpellerRule) rule).addIgnoreTokens(Arrays.asList(moreIgnoredWords));
break;
}
}
If you have a reference to the rule, calling "spellingRule.addIgnoreTokens(ignored); " should work, no matter if you have added the rule already. If that doesn’t work, could you maybe post a small self-contained example that shows the problem?