<!-- HÁ n SEGUNDOS/MINUTOS/HORAS/DIAS/SEMANAS/MESES/ANOS ATRÁS (remove "ATRÁS") -->
<rule id="HÁ-ATRÁS" name="há n tempo atrás">
<pattern>
<token skip="-1">há</token>
<token regexp="yes">segundos?|minutos?|horas?|dias?|semanas?|mês|meses|anos?</token>
<token>atrás</token>
</pattern>
<message>Com o verbo haver não é necessário usar "atrás": <suggestion><match no="1" include_skipped="all"/> <match no="2"/></suggestion>.</message>
<example correction="Há n segundos"><marker>Há n segundos atrás</marker>.</example>
</rule>
Tiago improved it to:
<!-- HÁ n SEGUNDOS/MINUTOS/HORAS/DIAS/SEMANAS/MESES/ANOS ATRÁS (remove "ATRÁS") -->
<rule id="HÁ-ATRÁS" name="há n tempo atrás">
<pattern>
<token>há</token>
<token min="0" regexp="yes">quase|poucos?|alguns|cerca</token>
<token skip="4"><exception scope="next" postag='VM[CIS][CFIMPS][0123][SP]0' postag_regexp='yes'></exception></token>
<token regexp="yes">segundos?|minutos?|horas?|dias?|semanas?|mês|meses|anos?|tempos?</token>
<marker>
<token>atrás</token>
</marker>
</pattern>
<message>Com o verbo haver não é necessário usar "atrás": <suggestion></suggestion>.</message>
<example correction="">Há n segundos <marker>atrás</marker>.</example>
</rule>
But it doesn’t show a correction example/suggestion now.
I tried changing it to the following but TESTRULES PT gives errors:
<!-- HÁ n SEGUNDOS/MINUTOS/HORAS/DIAS/SEMANAS/MESES/ANOS ATRÁS (remove "ATRÁS") -->
<rule id="HÁ-ATRÁS" name="há n tempo atrás">
<pattern>
<token>há</token>
<token min="0" regexp="yes">quase|poucos?|alguns|cerca</token>
<token skip="4"><exception scope="next" postag='VM[CIS][CFIMPS][0123][SP]0' postag_regexp='yes'></exception></token>
<token regexp="yes">segundos?|minutos?|horas?|dias?|semanas?|mês|meses|anos?|tempos?</token>
<token>atrás</token>
</pattern>
<message>Com o verbo haver não é necessário usar "atrás": <suggestion><match no="1" include_skipped="all"/> <match no="2"/></suggestion>.</message>
<example correction="Há n segundos"><marker>Há n segundos atrás</marker>.</example>
</rule>
@Yakov
You are the brain so I would like to ask you what needs to be changed.
It does suggest a blank space (""). There is a minor issue though, it creates a double space that is recognized afterwards.
Try replacing <token>atrás</token> with <token spacebefore="yes">atrás</token> and see if it works.
My idea was that it should show the full words to be replaced without the “atrás”, just like it used to do in the first version of the rule.
“há 10 horas atrás”
should suggest:
“há 10 horas”
just like it did before.
That would be ideal but I still do not know how to insert optional tokens on the suggestions (the ones with token min=‘0’).
My next project is to localize all rules from Spanish, Galician, French and Italian grammar.xml that apply to Portuguese. It is a low hanging fruit that allows hundreds of rules to be ported before the next release and it allows to learn while doing. I prefer not to be side tracked until that is done.
If you figure out how to do it tell me, because that would make suggestions for other rules viable.
<!-- HÁ n SEGUNDOS/MINUTOS/HORAS/DIAS/SEMANAS/MESES/ANOS ATRÁS (remove "ATRÁS") -->
<rule id="HÁ-ATRÁS" name="há n tempo atrás">
<pattern>
<token>há</token>
<token min="0" regexp="yes">quase|poucos?|alguns|cerca</token>
<token skip="4"><exception scope="next" postag='VM[CIS][CFIMPS][0123][SP]0' postag_regexp='yes'></exception></token>
<token regexp="yes">segundos?|minutos?|horas?|dias?|semanas?|mês|meses|anos?|tempos?</token>
<token>atrás</token>
</pattern>
<message>Com o verbo haver não é necessário usar "atrás": <suggestion><match no="1" include_skipped="all" ></match> <match no="2" include_skipped="all" ></match></suggestion>.</message>
<example correction="Há n segundos"><marker>Há n segundos atrás</marker>.</example>
</rule>