languagetool
languagetool copied to clipboard
Synthesis: check that postags are defined in the rule pattern
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>
The test gives warnings, but it is currently disabled because there are too many messages.
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?