Back to LanguageTool Homepage - Privacy - Imprint

[pt] Problem creating rule - 2021-10-07

Hello @jaumeortola @tiff @udomai

	<!-- DO INIMIGO/ADVERSÁRIO/ALIADO inimiga/adversário/aliada -->
    <rule id='INIMIGO_ADVERSÁRIO_ALIADO' name="Do(s) + inimigo(s)/adversário(s)/aliado(s) → inimiga(s)/adversária(s)/aliada(s)" type="style">
    <!--      Created by Marco A.G.Pinto, Portuguese rule 2021-10-07 (25-JUN-2021+)      -->
	<!--
O objetivo é alcançar a bandeira do inimigo. → O objetivo é alcançar a bandeira inimiga.
	-->
      <pattern>
		<token regexp='yes'>as?</token>
		<token postag='NC.+' postag_regexp='yes'>
			<exception postag_regexp='yes' postag='V.+'/>
		</token>
		<marker>
			<token regexp='yes'>dos?</token>
			<token regexp='yes'>inimigos?|adversários?|aliados?</token>
		</marker>		
      </pattern>      
	  <filter class="org.languagetool.rules.pt.AdvancedSynthesizerFilter" args="lemmaFrom:2 lemmaSelect:NCM(.)000 postagFrom:4 postagSelect:NCF$1000"/>
	  <message>Esta perífrase poder ser simplificada.</message>
	  <suggestion>{suggestion}</suggestion>	
      <example correction="inimiga">O objetivo é alcançar a bandeira <marker>do inimigo</marker>.</example>
	  <example>Sabiam localizar os rastros dos animais e as trilhas inimigas.</example>
    </rule>

TESTRULES PT gives the error:

2756 rules tested.
Exception in thread “main” org.languagetool.rules.patterns.PatternRuleTest$PatternRuleTestFailure: Test failure for rule INIMIGO_ADVERS?RIO_ALIADO[1] in file /org/languagetool/rules/pt/grammar.xml: Incorrect suggestions: Expected ‘inimiga’, got: ‘{suggestion}’ on input: ‘O objetivo é alcançar a bandeira do inimigo.’
at org.languagetool.rules.patterns.PatternRuleTest.addError(PatternRuleTest.java:322)
at org.languagetool.rules.patterns.PatternRuleTest.assertSuggestions(PatternRuleTest.java:582)
at org.languagetool.rules.patterns.PatternRuleTest.testBadSentences(PatternRuleTest.java:474)
at org.languagetool.rules.patterns.PatternRuleTest.lambda$testGrammarRulesFromXML$1(PatternRuleTest.java:357)
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…

Do you know how to fix it?

Thanks!

You are probably overlooking your rule specifies {suggestion} litterally…

The filter parameters are wrong. Use these:
<filter class="org.languagetool.rules.pt.AdvancedSynthesizerFilter" args="lemmaFrom:4 lemmaSelect:NC.* postagFrom:2 postagSelect:NC.*"/>

Ahhhhh… it is working!!! Thanks!

It has been implemented:

Thanks!