I want to exclude certain patterns from spell checking. Especially things between square brackets. So I put this rule on top inside the rules tag of a grammar.xml:
<category id="BRACKETS" name="brackets">
<rule id="IGNORE_BRACKETS" name="Ignore text in brackets">
<pattern>
<token regexp="yes">\[.*?\]</token>
</pattern>
<disambig action="immunize"/>
</rule>
</category>
I also tried with:
<disambig action="ignore_spelling"/>
Both didn’t work.
I wrote some extra sentences in my test example to make sure the correct language is selected.
I didn’t put the rule inside grammar_custom.xml to reduce error possibilities.
Your help would be highly appreciated.
Best,
yellowblob
[ and ] are their own tokens, you can check that at Text Analysis - LanguageTool. So you’ll need three <token...> elements for that in your pattern. The action should also maybe be <disambig action="ignore_spelling"/> (if you really only want to exclude spell checking).
I did two mistakes. First was putting the snippet in org/languagetool/rules/xx/grammar.xml. It has to go in org/languagetool/resource/xx/disambiguation.xml Second as @dnaber pointed out it needs three tokens.
<rule id="IGNORE_BRACKETS" name="Ignore text in brackets">
<pattern>
<token>[</token>
<token></token>
<token>]</token>
</pattern>
<disambig action="ignore_spelling"/>
</rule>
One question for me remains: Is there a more suitable location for the rule to ensure it persists through updates?