SpellingCheckRule.acceptPhrases fails on repeating words

The spellingCheckRule.acceptPhrases function doesn’t seem to allow to ignore certain/all grammar errors such as repeating words.

For e.g. certain Australian towns like “Banda Banda”, “Balla Balla” are marked in red and cannot be ignored using this function. Am I using it incorrectly or is there a workaround to fix this?

Thanks for the report, could you post a small code snippet that shows the problem?

                final List<String> phrasesToIgnore = new ArrayList<>();

                phrasesToIgnore.add("the she");
                phrasesToIgnore.add("mok wokz");
                phrasesToIgnore.add("Banda Banda");
                phrasesToIgnore.add("Balla Balla");


                if (!phrasesToIgnore.isEmpty()) {
                    languageTool.getAllActiveRules()
                            .stream()
                            .filter(rule -> rule instanceof SpellingCheckRule)
                            .forEach(rule -> ((SpellingCheckRule) rule).acceptPhrases(phrasesToIgnore));
                }

This would remove highlighting of only “mok wokz” if you type:

She lives in Banda Banda but travels to Balla Balla mok wokz in the she hate to.

image

Have you checked that these matches actually come from the speller? “Balla Balla”, for example, will also trigger the word repetition rule.

Yes the matches are generated by the languageTool.
`matches = languageTool.check(textArea.getText());

Yes they trigger the word repetition rule. What I am expecting is to ignore that error by using the acceptPhrases method.

acceptPhrases will only ignore the phrases for the speller rule. Other rules are independent of that and can still trigger. You might try immunize in the disambiguator as an alternative.

Ah ok, thanks for explaining.
Are there any code examples of using immunize in a java application?

You can’t use that if you’re an API consumer. The Java rules need to take immunization into consideration. But as a user, you could write a rule in disambiguation.xml, as described in the link above.