languagetool-org / languagetool

Style and Grammar Checker for 25+ Languages
https://languagetool.org
GNU Lesser General Public License v2.1
12.29k stars 1.39k forks source link

[en] An exception does not give the expected result #6244

Open MikeUnwalla opened 2 years ago

MikeUnwalla commented 2 years ago

The testrules tests pass for this rule:

<rule id="INFLECTED_EXCEPTION_TEST" name="Inflected exception test">
    <pattern>
      <token regexp="yes">m.+
        <exception inflected="yes">moment</exception>
      </token>
    </pattern>
    <message>The word starts with 'm', but is not 'moment'.</message>
    <example type="incorrect">See you in a <marker>minute</marker>.</example>
    <example type="incorrect"><marker>Magnificent</marker>!</example>
    <example type="incorrect">All <marker>merchants</marker> will obey these rules:</example>
    <example type="correct">In a <marker>moment</marker> the play will start.</example>
    <example type="correct">I was happy for a few <marker>moments</marker>.</example>
    <example type="triggers_error">At the <marker>moment</marker>, the problem is not solved.</example>
</rule>

Because of the exception, the last sentence should not trigger an error.

If I change the exception to use a regexp, the last sentence does not trigger an error: <exception regexp="yes">moments?</exception>

MikeUnwalla commented 2 years ago

All the words in the exception (except 'actor') are not ignored by the rule.

<rule id="INFLECTED_EXCEPTION_TESTv2" name="Inflected exception test v2">
    <pattern>
      <token regexp="yes">[a-z].+
        <exception regexp="yes" inflected="yes">actor|backdated|bated|bifidobacteria|binoculars|blubbering|blubbing|calipers|callipers|carousing|cognoscenti|cyanobacteria|debarred|doth|earnings|errata|Europeanised|Europeanized|goggles|innings|keyboarding|me|measles|minima|minutiae|mollified|moneys|nos|overpriced|pajamas|Parkerised|Parkerises|Parkerising|pyjamas|sated|shrouded|slaked|snooping|spectacles|stats|stokes|surefire|throes|transfixing|unfreezing|unshackled|us</exception>
      </token>
    </pattern>
    <message>This is a word.</message>
    <example type="incorrect"><marker>test</marker></example>
    <example type="correct"><marker>actor</marker></example>
    <example type="triggers_error"><marker>backdated</marker></example>
    <example type="triggers_error"><marker>bated</marker></example>
    <example type="triggers_error"><marker>bifidobacteria</marker></example>
    <example type="triggers_error"><marker>binoculars</marker></example>
    <example type="triggers_error"><marker>blubbering</marker></example>
    <example type="triggers_error"><marker>blubbing</marker></example>
    <example type="triggers_error"><marker>calipers</marker></example>
    <example type="triggers_error"><marker>callipers</marker></example>
    <example type="triggers_error"><marker>carousing</marker></example>
    <example type="triggers_error"><marker>cognoscenti</marker></example>
    <example type="triggers_error"><marker>cyanobacteria</marker></example>
    <example type="triggers_error"><marker>debarred</marker></example>
    <example type="triggers_error"><marker>doth</marker></example>
    <example type="triggers_error"><marker>earnings</marker></example>
    <example type="triggers_error"><marker>errata</marker></example>
    <example type="triggers_error"><marker>Europeanised</marker></example>
    <example type="triggers_error"><marker>Europeanized</marker></example>
    <example type="triggers_error"><marker>goggles</marker></example>
    <example type="triggers_error"><marker>innings</marker></example>
    <example type="triggers_error"><marker>keyboarding</marker></example>
    <example type="triggers_error"><marker>me</marker></example>
    <example type="triggers_error"><marker>measles</marker></example>
    <example type="triggers_error"><marker>minima</marker></example>
    <example type="triggers_error"><marker>minutiae</marker></example>
    <example type="triggers_error"><marker>mollified</marker></example>
    <example type="triggers_error"><marker>moneys</marker></example>
    <example type="triggers_error"><marker>nos</marker></example>
    <example type="triggers_error"><marker>overpriced</marker></example>
    <example type="triggers_error"><marker>pajamas</marker></example>
    <example type="triggers_error"><marker>Parkerised</marker></example>
    <example type="triggers_error"><marker>Parkerises</marker></example>
    <example type="triggers_error"><marker>Parkerising</marker></example>
    <example type="triggers_error"><marker>pyjamas</marker></example>
    <example type="triggers_error"><marker>sated</marker></example>
    <example type="triggers_error"><marker>shrouded</marker></example>
    <example type="triggers_error"><marker>slaked</marker></example>
    <example type="triggers_error"><marker>snooping</marker></example>
    <example type="triggers_error"><marker>spectacles</marker></example>
    <example type="triggers_error"><marker>stats</marker></example>
    <example type="triggers_error"><marker>stokes</marker></example>
    <example type="triggers_error"><marker>surefire</marker></example>
    <example type="triggers_error"><marker>throes</marker></example>
    <example type="triggers_error"><marker>transfixing</marker></example>
    <example type="triggers_error"><marker>unfreezing</marker></example>
    <example type="triggers_error"><marker>unshackled</marker></example>
    <example type="triggers_error"><marker>us</marker></example>
</rule>

Removeinflected="yes" and the rule operates correctly.