Stricter regexp_match / optional suggestions in xml fules

Often I have a rule where suggestions may differ for different cases. Currently it’s impossible and all suggestions provided in the rule always appear.
In this case I either have to give all possible suggestions in the list or I have to split the same rule into multiple, duplicating the logic and making it slower.

And currently if regexp_match does not match, we just don’t replace and leave the original in place.
This has a problem of having unintended suggestion (as often it’s impossible to cover all cases in tests).

Proposal: add new boolean attribute: match_strict or match_as_filter.
If set to true, and regexp_match does not match we’ll skip the suggestion.
We could even do it “yes” by default - this will force us to fix all rules where regexp_match didn’t apply.

So I’ve pushed a branch to introduce “if_match” attribute on “match” element. If it’s set to “yes” and regexp_match does not match we’ll remove the suggestion altogether.
This allows more flexible way to add only relevant suggestions.
I would appreciate any feedback.

1 Like

Could you clarify with an (english) example?

Now that I am thinking about it, this attribute should probably also apply to postag= in the <match> - I’ll take a look.

I got the filtering suggestion by postags mostly implemented but need a bit more time to test it properly.