languagetool icon indicating copy to clipboard operation
languagetool copied to clipboard

Synthesis: check that postags are defined in the rule pattern

Open jaumeortola opened this issue 2 years ago • 2 comments

A test to avoid runtime exceptions.

Check that the postag in the token (A.*) requires the postag that will be used in the synthesis match ((A.*)).

<rule>
  <pattern>
      <token postag="A.*" postag_regexp="yes"/>
  </pattern>
  <message></message>
  <suggestion><match no="1" postag_regexp="yes" postag="(A.*)" postag_replace="$1"></match></suggestion>
</rule>

jaumeortola avatar Sep 08 '22 11:09 jaumeortola

The test gives warnings, but it is currently disabled because there are too many messages.

jaumeortola avatar Sep 13 '22 20:09 jaumeortola

The current test wouldn't have prevented this error: https://github.com/languagetool-org/languagetool/commit/9b7c55889e3485fb089ac086161b2dd8b749bf0e The only way to prevent this kind of errors is to require the same regexp in the synthesis match and the pattern token (~~except for the parenthesis~~including parentheses). Could that be too strict?

jaumeortola avatar Sep 16 '22 07:09 jaumeortola