Suggesting a different form of a word

I'm trying to write a rule that matches a verb in 3rd person singular (in whatever tense) and suggests the plural, but all the other grammatical properties of the matched verb form should carry over to the replacement. Here is what I have so far:
<rulegroup id="USA_PLURAL" name="Grammatik: 'Die USA ist (sind)' etc. (falscher Singular)">    
            <!-- This should be covered by DE_SUBJECT_VERB_AGREEMENT but apparently isn't. -->
            <!-- Perhaps the tagger dict isn't 100 % correct. -->
                        <token postag="SENT_START"/>
                        <token regexp="yes" case_sensitive="yes">USA|UN|AGB|SBB</token>
                            <token postag="VER:([A-Z]{3}:)?3:SIN:.+" postag_regexp="yes"><exception postag="VER:([A-Z]{3}:)?3:PLU:.+" postag_regexp="yes"/></token>
                    <message>Müsste dieses Verb im Plural stehen? Stehen Kurzwörter wie 'USA', 'UN', 'AGB' als Subjekt im Satz, muss das dazugehörige Verb im Plural stehen.</message>
                    <suggestion><match no="4" postag="VER:([A-Z]{3}:)?3:PLU:.+" postag_regexp="yes"/></suggestion>
                    <short>Müsste dieses Verb im Plural stehen?</short>
                    <example correction="haben|hatten|hätten">Die USA <marker>hat</marker> eine besondere Verantwortung.</example>
                    <example correction="tragen|trugen|trügen">Die USA <marker>trägt</marker> eine besondere Verantwortung.</example>


It’s very close to what I want, but I would like to remove the ‘hatten’ and ‘hätten’ from the suggestions. Is there a way to reference the POS tags of the word that actually matched, and just replace SIN with PLU?

Also, why isn’t the example sentence covered by DE_SUBJECT_VERB_AGREEMENT?

As it turns out, this is what I get when I tag ‘USA’:


I’ve always taken it for granted that ‘USA’ is a plural masculine, because ‘state’ translates to ‘der Staat’. IMO, the correct and complete tags would be:


or perhaps


which would leave the question of gender open.

At least one person over at Duden seems to think along the same lines:

“postag_regexp” and “postag_replace” should do that, maybe like (not tested):

postag_regexp="SIN" postag_replace="PLU"

“UN” also has the “:NOG” tags, I think that’s the correct way. Actually “USA” is already in added.txt and could be changed to “…:NOG” I guess.

Thanks, Daniel, I will try “postag_replace”.

Do you agree that the entries that flag USA as SIN:FEM should be removed from german.dict? According to Duden ‘USA’ is plural-only (“Pluraletantum”). The problem is I don’t know how to extract the dictionary.

Yes, but we don’t want to touch the binary file for all the small errors we find. Instead, feel free to create a file “remove.txt” that is the opposite of added.txt. It needs some code to become active, I can put that on my TODO list.

When I use ‘postag_regexp=“SIN”’ I get:

cvc-enumeration-valid: Wert "SIN" ist nicht Facet-gültig in Bezug auf Enumeration "[yes, no]". Er muss ein Wert aus der Enumeration sein. Problem found at line 24772, column 85.

That makes sense, so I tried

<match no="4" postag="SIN" postag_replace="PLU"/>

but this gives the following error:

Exception in thread "main" junit.framework.AssertionFailedError: German: Incorrect suggestions: [haben] != [] for rule USA_PLURAL[1]:[/SENT_START, Die, USA|UN|AGB|SBB, /VER:([A-Z]{3}:)?:SIN:.+/exceptions=[/VER:([A-Z]{3}:)?3:PLU:.+]]:Grammatik: 'Die USA ist (sind)' etc. (falscher Singular) on input: Die USA hat eine besondere Verantwortung. expected:<[haben]> but was:<[]>

I’m stuck.

I think I found something on the LT wiki.
For the record, this is what eventually worked:

<match no="4" postag="(.*)SIN(.*)" postag_regexp="yes" postag_replace="$1PLU$2"/>

It is actually the most straightforward solution when you think of it: The two (.*) match everything except the SIN, and $1 and $2 make sure everything from the postag of the match is preserved, except the SIN. A very powerful tool.