Back to LanguageTool Homepage - Privacy - Imprint

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

Hello @udomai @jaumeortola

I have been trying to create the following rule:

	<!-- QUE NA/NAS/NO/NOS NOME É/SÃO/ERA/ERAM NOME/ADJETIVO nome/adjetivo na/nas/no/nos nome -->
    <rule id='QUE_NA-NAS-NO-NOS_NOME-ADJETIVO_É-SÃO-ERA-ERAM_NOME-ADJETIVO' name="Que na(s)/no(s) nome/adjetivo é/são/era/eram nome/adjetivo → ,nome/adjetivo na/nas/no/nos nome" type="style">
    <!--      Created by Marco A.G.Pinto, Portuguese rule 2021-07-02 (25-JUN-2021+)      -->
	<!--
Temos uma teoria que na matemática era absoluta. → Temos uma teoria, absoluta na matemática.
	-->
      <pattern>
			<token min="0" max="1" spacebefore='no' regexp='yes'>[,]</token>
			<token>que</token>
			<token regexp='yes'>nas?|nos?</token>
			<token postag='NP.+|AQ0.+|NC.+' postag_regexp='yes'/>
			<token regexp='yes'>é|são|eram?</token>
			<token postag='NP.+|AQ0.+|NC.+' postag_regexp='yes'/>
			<token spacebefore='no' postag='_PUNCT' postag_regexp='no'/>			
      </pattern>
      <message>Esta perífrase poderá ser simplificada.</message>
	  <suggestion>, \6 \3 \4\7</suggestion>
      <example correction=", absoluta na matemática.">Temos uma teoria <marker>que na matemática era absoluta.</marker></example>
    </rule>

It works well with the stand-alone tool, but TESTRULES PT throws some errors:

Testing rule 2700…
Skipped 0 rules for variant language to avoid checking rules more than once
2715 rules tested.
Exception in thread “main” org.languagetool.rules.patterns.PatternRuleTest$PatternRuleTestFailure: Test failure for rule QUE_NA-NAS-NO-NOS_NOME-ADJETIVO_É-S?O-ERA-ERAM_NOME-ADJETIVO[1] in file /org/languagetool/rules/pt/grammar.xml: Incorrect match position markup (expected match position: 17 - 48, actual: 16 - 48) in sentence: Temos uma teoria que na matemática era absoluta.
at org.languagetool.rules.patterns.PatternRuleTest.addError(PatternRuleTest.java:339)
at org.languagetool.rules.patterns.PatternRuleTest.testBadSentences(PatternRuleTest.java:482)
at org.languagetool.rules.patterns.PatternRuleTest.lambda$testGrammarRulesFromXML$1(PatternRuleTest.java:368)
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…
100…
200…
293 rules tested (429ms)
Disambiguator tests successful.
Running XML bitext pattern tests…
Bitext pattern tests successful.
Validating false-friends.xml…
Validation successfully finished.

Do you know what is wrong with it?

Thanks!