Currently setting SENT_END on the last token makes some rules a bit flaky.
Consider these two sentences in https://languagetool.org/
He pointed to it’s reddest area.
He pointed to it’s reddest area
First generates an error, while second does not.
The reason is that negate_pos=“yes” on the last token in the rule need to take to account SENT_END and many rules (if not most) do not. To allow the rule to work for sentence that ends on the last word you have to add “|SENT_END” to the postag attribute. That’s a bit tricky to remember.
See the patch below to illustrate this in grammar.xml
What’s worse your last token may also get PARA_END (I suspect you can’t trigger that in grammar.xml but it happens on real texts via command line or REST API).
So technically on any rule that has negate_pos in the last token you need to add “|SENT_END|PARA_END”.
This technically may also apply to some Java rules (I know I noticed this moment with SENT_END while writing some of Ukrainian Java rules, but I don’t think even accounted for PARA_END).
diff --git a/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/grammar.xml b/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/grammar.xml index d4e8d21..68603d2 100644 --- a/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/grammar.xml +++ b/languagetool-language-modules/en/src/main/resources/org/languagetool/rules/en/grammar.xml @@ -2990,6 +2990,8 @@ </pattern> <message>Did you mean <suggestion>its <match no="4"/> <match no="5"/></suggestion>?</message> <example correction="its reddest area">For the painting, <marker>it's reddest area</marker> was in the upper left.</example> + <example correction="its reddest area">He pointed to <marker>it's reddest area</marker>.</example> + <example correction="its reddest area">He pointed to <marker>it's reddest area</marker></example> </rule> <!-- for it's .*/JJ|NN|NNS::word=for its::pivots=\1,its --> <rule id="FOR_ITS_NN" name="for its NN (possessive)">