Back to LanguageTool Homepage - Privacy - Imprint

How do I match the tense of a previous verb?

Hello! I am trying to figure out a solution to a suggestion when I want to inflect a verb to match the tense of a verb I am replacing. Here’s a pattern and example:

<token inflected="yes">proceed<exception>proceeding</exception></token>
<token>to</token>
<token postag="VB"/>

This pattern will flag the following:

He proceeded to schedule an interview.

Suppose I wish to change the sentence to “He went on to schedule an interview.” This is straightforward:

<suggestion><match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">go</match> on to \3</suggestion>

My question is: What happens when I want to change the sentence to “He scheduled an interview.”? The issue is that the verb is detected as a VB so I do not have it at the time I am writing the rule. It’s “dynamic” in the sense that I don’t know it until a sentence is run. Is there a way to accomplish this?

I naively tried the following, which doesn’t do anything:

<match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">\3</match>

And this naive pattern creates “He scheduleed an interview.” (incorrect):

<suggestion>\3<match no="1" regexp_match="proceed(.*)" regexp_replace="$1"/></suggestion>

Any suggestions would be helpful. Thank you!

Here is the rule I am trying to work with:

	<rule id="PROCEED_TO_VB" name="proceed to VB">
		<pattern>
			<token inflected="yes">proceed<exception>proceeding</exception></token>
			<token>to</token>
			<token postag="VB">
			</token>
		</pattern>
		<message>Shortening this sentence may make it clearer.</message>
		<suggestion>\3<match no="1" regexp_match="proceed(.*)" regexp_replace="$1"/></suggestion>
		<suggestion>then \3</suggestion>
		<suggestion><match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">go</match> on to \3</suggestion>
		<example correction="scheduled|then scheduled|went on to schedule">He <marker>proceeded to schedule</marker> an interview.</example>
	</rule>

The first suggestion fails because I’m trying to get “to schedule” to conjugate against “He”. Any insights are appreciated. Thanks!

Hi @Tyler!

Without having tried it, here is a general tip: The regexp_match and replace can sometimes be prone to bugs. I suggest working with the postags instead:

So, does it work if instead of this:

<match no="1" regexp_match="proceed(.*)" regexp_replace="$1"/>

you do this:

<match no="1" postag="VBP"/>

?

Hi @udomai

Yes, this is a fantastic start. However, when we declare:

<match no="1" postag="VBP"/>

What we are actually trying to do is conjugate “schedule” into the same form as “proceed” when we don’t know the form of “proceed” until runtime. When we declare VBP, we are assuming that match 1 is non-3rd person singular present, but it might not be if “proceed” is a different form.

The only workaround I can think of right now is to create at least three different rules targeting the different forms of “proceed” and using the correct postag explicitly.

Hi @Tyler,

I see! You need to transfer the postag of \1 (any form of proceed, but it needs to be a verb form) to the verb in \3.

In the suggestion, if you want a matching form of the verb in \3, you can use our AdvancedSynthesizerFilter which was made exactly for this kind of situation. This way, you only need one rule:

	<rule id="PROCEED_TO_VB" name="proceed to VB">
		<pattern>
			<token postag="V.*" postag_regexp="yes" inflected="yes">proceed<exception>proceeding</exception></token>
			<token>to</token>
			<token postag="VB"/>
		</pattern>
        <filter class="org.languagetool.rules.en.AdvancedSynthesizerFilter" args="lemmaFrom:3 lemmaSelect:V.* postagFrom:1 postagSelect:V.*"/>
		<message>Shortening this sentence may make it clearer.</message>
		<suggestion>{suggestion}</suggestion>
		<suggestion>then {suggestion}</suggestion>
		<suggestion><match no="1" postag="(V.*)" postag_regexp="yes" postag_replace="$1">go</match> on to \3</suggestion>
		<example correction="scheduled|then scheduled|went on to schedule">He <marker>proceeded to schedule</marker> an interview.</example>
	</rule>

The documentation about this filter can be found here.

This is incredible! Great, I will dig into this documentation. I appreciate your help! :smile:

1 Like