ID: eliminacao_repeticao_com_adjetivo
Name: Simplificação de atribuição de adjetivo a sintagma nominal
Suggestion: Os adjetivos que estão modificando os substantivos podem ser simplificados, utilizando-se apenas um.
You want to match this within the pattern, right? In that case, it’s
<token><match no="3"/></token> to match the fourth (!) token.
P.S.:
Caution: If you refer to the fourth token outside of the pattern, for example in the suggestion, it’s <suggestion><match no="4" .../></suggestion>...
<!-- COM + E COM com -->
<rule id='ELIMINAÇÃO_REPETIÇÃO_COM_ADJETIVO' name="Simplificar atribuição de adjetivo a sintagma nominal" type="style">
<!-- Created by Marco A.G.Pinto with Ricardo Joseh Lima suggestions, Portuguese rule 2022-06-01 (24-MAY-2022+) -->
<!--
Pareço um maluco com a barba grande e com o cabelo grande. → Pareço um maluco com a barba e o cabelo grandes.
Pareço um maluco com a barba grande e o cabelo grande. → Pareço um maluco com a barba e o cabelo grandes.
-->
<!--
1 com
2 a
3 barba
4 grande
5 e
6 com
7 o
8 cabelo
9 grande
-->
<pattern>
<marker>
<token>com</token>
<token>a</token>
<token postag='NC.+' postag_regexp='yes'/>
<token postag='AQ.+' postag_regexp='yes'/>
<token>e</token>
<token>com</token>
<token>o</token>
<token postag='NC.+' postag_regexp='yes'/>
<token><match no="3"/></token>
</marker>
</pattern>
<message>Os adjetivos que modificam os substantivos podem ser simplificados, utilizando-se apenas um.</message>
<suggestion>\1 \2 \3 e \7 \8 <match no='4' postag='AQ.+' postag_regexp="yes" postag_replace='AQ..P0'/></suggestion>
<example correction="com a barba e o cabelo grandes">Pareço um maluco <marker>com a barba grande e com o cabelo grande</marker>.</example>
</rule>
But, TESTRULES PT gives an error, and I am too stress and can’t find out what is wrong (it seems to add spaces in the suggestions:
Testing rule 2800...
Skipped 0 rules for variant language to avoid checking rules more than once
2828 rules tested.
Exception in thread "main" org.languagetool.rules.patterns.PatternRuleTest$PatternRuleTestFailure: Test failure for rule ELIMINAÇ?O_REPETIÇ?O_COM_ADJETIVO[1] in file /org/languagetool/rules/pt/grammar.xml: Incorrect suggestions: Expected 'com a barba e o cabelo grandes', got: 'com a barba e o cabelo grandes' on input: 'Pareço um maluco com a barba grande e com o cabelo grande.'
at org.languagetool.rules.patterns.PatternRuleTest.addError(PatternRuleTest.java:347)
at org.languagetool.rules.patterns.PatternRuleTest.assertSuggestions(PatternRuleTest.java:611)
at org.languagetool.rules.patterns.PatternRuleTest.testBadSentences(PatternRuleTest.java:503)
at org.languagetool.rules.patterns.PatternRuleTest.lambda$testGrammarRulesFromXML$1(PatternRuleTest.java:382)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Running disambiguator rule tests...
Running disambiguation tests for Portuguese...