Back to LanguageTool Homepage - Privacy - Imprint

Agreement on replacing


(Ruud Baars) #1

If I have to replace a 'de-word' with a 'het-word' (de/het = der/das in German), how do I get the area arlound the word correct, including the de and het themselves, but it also affects adjectives.
Any hints or examples?


(Tiago F. Santos) #2

<suggestion><match no='1' regexp_match='de-(.+)' regexp_replace='het-$1'/></suggestion>
(.+) is captured and used as $1 in the replace. If you capture more than one component (e.g.(.+)-het-(.+)) reference then by $1, $2, etc.


(Ruud Baars) #3

Thanks, but you took my text too litterally. I meant : how to make the surrounding words match the replaced word. Like a construction around a female word has to change in one around a male word...


(Tiago F. Santos) #4

It may not work for Dutch inflections, but I use to use this trick:

<suggestion>\1 <match no='1' regexp_match='(.+?)-(.+)' regexp_replace='$1-'/><match no='2' regexp_match='(.+?)-(.+)' regexp_replace='$2'/></suggestion>

this example would:
1- Suggest the 1st word +
2- Capture the first compound of the 1st word (e.g. 'de' or 'het') +
3- Capture the 2nd compound.

For "de-word1 het-word2' the suggestion would look like "de-word1 de-word2".