Situation:
As a workaround for the not yet implemented feature to add a user dictionary of words to Languagetool, I came up with this code snippet:
JLanguageTool langTool = new JLanguageTool(lang);
langTool.activateDefaultPatternRules();
List<Rule> rules = langTool.getAllActiveRules();
for (Rule rule:rules) {
// System.out.println(rule.getId());
if (rule.getId().equals("GERMAN_SPELLER_RULE")) {
if (rule instanceof SpellingCheckRule) {
SpellingCheckRule srule=(SpellingCheckRule) rule;
String [] words={"word1", "word2"};
List<String> tokens=new ArrayList<String>();
for (String word:words) {
tokens.add(word);
}
srule.addIgnoreTokens(tokens);
}
}
}
which will nicely add the list of words specified by
String [] words={"word1", "word2"};
to the list of ignored words. But how about word combinations/two word patterns like "Guest bathroom", "French word" "test application" - how could I get these ignored without modifying the orginal grammar file? I assume creating some user defined rule could do the trick and might also be a more elegant solution for the above code snippet.
Question:
What would be a working approach to get a user-dictionary work-around going that ignores single and two-word phrases?