Here is a simple rule for “I am” and “am I”
<rule id="I_AM" name="I am" >
<pattern>
<marker>
<token>I<exception scope="previous" postag_regexp="yes" postag="VBG|VBP" /></token>
</marker>
<token postag='VBG'></token>
</pattern>
<message>Did you mean <suggestion>I am</suggestion>?</message>
<example type="correct">I am looking into the problem.</example>
<example type="incorrect">I looking into the problem.</example>
</rule>
<rule id="AM_I" name="am I" >
<pattern>
<marker>
<token>am<exception scope="previous">I</exception></token>
</marker>
<token postag='VBG'></token>
</pattern>
<message>Did you mean <suggestion>am I</suggestion>?</message>
<example type="correct">Whom am I talking with</example>
<example type="incorrect">Whom am talking with</example>
</rule>
Both rules seem OK when tested on the LanguageTool Rule Editor.
Currently both rules only relate to “I” and “Am” before a VBG, however I expect with use I might identify other situations.
Thanks