Plural noun following 'a/an'

I was trying to come up with a rule which prohibits plural nouns to follow ‘a/an’.

<rule id="A_FOLLOW_PLURAL" name="a/an should not be followed by an expression containing plural nouns">
    <pattern>
        <token regexp="yes" chunk="B-NP-plural">a|an</token>
        <token chunk="I-NP-plural" min="0" max="4"/>
        <marker>
            <token postag="NNS" chunk="E-NP-plural"> </token>
        </marker>
    </pattern>
    <message>'A' or 'an' should not be follwed by an expression containing plural nouns:<suggestion><match no="3" postag="NN"/></suggestion></message>
    <example type="correct">This work was done by a student.</example>
    <example type="correct">He was considered as a diamond by many people.</example>
    <example type="incorrect" correction="company">He had a fight wth a big trading <marker>companies</marker>.</example>
</rule>

I know that this rule will not be applicable in many scenarios(a dozen eggs etc.). But I would like to ask, for this rule definition, why is the suggestion not working properly for the incorrect example. It would really help if the answer could be focussed on resolving this error.

I had also referred to the Rule ID =“A_PLURAL”, but the rule does not serve the purpose when there are expressions like ‘a big trading companies’.

@nancyntse13,

Use ‘testrules’ to find problems with rules.Refer to Tips and Tricks - LanguageTool Wiki.

Running XML validation for en/grammar.xml...
Running pattern rule tests for English... Exception in thread "main" java.lang.AssertionError: English: Incorrect sugges
tions: [company] != [] for rule A_FOLLOW_PLURAL[1] on input: He had a fight wth a big trading companies. expected:<[comp
any]> but was:<[]>

The marked token contains a space. To prevent this type of problem, use: <token postag="NNS" chunk="E-NP-plural"/>

The singular noun ‘company’ has the postag NN:UN.

Try this:

<rule id="A_FOLLOW_PLURAL" name="a/an should not be followed by an expression containing plural nouns">
    <pattern>
        <token regexp="yes" chunk="B-NP-plural">a|an</token>
        <token chunk="I-NP-plural" min="0" max="4"/>
        <marker>
            <token postag="NNS" />
        </marker>
    </pattern>
    <message>'A' or 'an' should not be follwed by an expression containing plural nouns:<suggestion><match no="3" postag_regexp="yes" postag="NN(:UN)?"/></suggestion></message>
    <example type="correct">This work was done by a student.</example>
    <example type="correct">He was considered as a diamond by many people.</example>
    <example type="incorrect" correction="company">He had a fight wth a big trading <marker>companies</marker>.</example>
    <example type="incorrect" correction="block">This is a test with a big test <marker>blocks</marker>.</example>
</rule>

Thanks for the help.