Back to LanguageTool Homepage - Privacy - Imprint

Control case of suggestion and control suggestions for missing tokens


(Harshdeep Gupta) #1
<rule>
        <pattern>
        	<token regexp="yes" inflected="yes" skip="-1">submit|present</token>
        	<marker>
        	 <token min="0" max="1">the</token>
            <token regexp="yes">director</token>
        	</marker>
        </pattern>
        <message>\2 needs to be preceded by "to" :<suggestion>to \2 \3</suggestion></message>
        <short>Incorrect verb form</short>
         <example correction="to director">Presented findings <marker>director</marker> of Compliance.</example>
	</rule>

In the above rule, I have 2 issues. First is that when there is no "the" after first token, the suggestion comes wrong ( the first match comes in the suggestion) , whereas I want it to show "the" in the suggestion depending on if there is one in source sentence.

Another issue is, if we remove the <token min="0" max="1">the</token> line from the above rule, the suggesition is "To director" whereas I want the suggestion to be "to director". Why it is automatically changing the case and how do I control this behaviour.


(jaumeortola) #2

I suggest writting two rules: one with "the" and another one without "the".

The skip="-1" is to greedy. You need to put a lower skip number or to add some exceptions.

For example:

   <antipattern>
         <marker>
              <token>to</token>
              <token min="0">the</token>
              <token>director</token>
         </marker> 
     </antipattern>