Back to LanguageTool Homepage - Privacy - Imprint

[PT] Object Pronoun in the middle of the verb

Hi, everyone!

I’ve been working on a rule that corrects the object pronoun (in the beginning of the sentence) when it is after a verb in the ‘future of the past’. This is the rule:

<rule id="MESOCLISE_FUTURO_DO_PRETERITO__OBJETO_DIRETO"  name="Mesoclise_futuro do preterito_2 conjugacao_objeto direto">
  <token postag='SENT_START' postag_regexp='yes'></token>
  <token postag='VMIC(1|3)S.*' postag_regexp='yes'></token>
  <token postag='PP3(M|F)(S|P)A.*' postag_regexp='yes'></token>
 <message>Colocação pronominal inadequada. <suggestion><match no="2" regexp_match="(.+)[aeio]ria$" regexp_replace="$1"/>-l<match no="4"/>-ia</suggestion></message>
 <example correction=''><marker>Amaria-o</marker>. Venderia-o. Partiria-o. Atribuiria-o. Poria-o.</example>
 <example correction=''>Venderia-o.</example>
 <example correction=''>Partiria-o.</example>
 <example correction=''>Atribuiria-o.</example>
 <example correction=''>Poria-o.</example>

The problem is in the suggestion (regexp). In general, verbs ended in a, e, i, o receive the accent: á, ê, í, ô, respectivelly. I´m not being able to suggest using the accents. Can anybody help me out, please?

Are you familiar with Java? I think what you need cannot be done with a single regex. You’d probably need a simple filter implemented in Java that takes the rule match and modifies it by adding the special characters where needed.

What if I had other characters? For exemple: instead of using ’ á ', I would use a simple ’ Z '. Would you think I still would have to use Java?

Maybe my understanding of regex is not complete, but I think you can only replace one character by another with a single regex, not a character class by another character class (like [aei] by [áêí]). A workaround might be to have one rule for each special character.