[pt] Redundancy rule

@rjlima

Hello Ricardo!

This one appeared on my mind today:

Pareço um maluco com a barba grande e com o cabelo grande.
> Pareço um maluco com a barba e o cabelo GRANDES.
> redundância TYPE

Is it a good try?

Should the adjective be plural “GRANDES”? I believe so, but to be 100% sure I am asking.

Thanks!

1 Like

Definitely worth a try, and yes grandeS.

@rjlima

Cool!

Do you have an ID, rule name and suggestion message for it?

I will work on the rule tonight.

Thanks!

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.

@jaumeortola @udomai

Hello!

I didn’t write down how to match a token years ago.

Could one of you tell me the command?

<token>com<token/>
<token>a<token/>
<token>barba<token/>
<token>grande<token/>
<token>e<token/>
<token>com<token/>
<token>o<token/>
<token>cobelo<token/>
<token>grande<token/> → MATCH TOKEN 4

Thanks!

Hi Marco!

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>...

Hello and thanks, @udomai

Dear @udomai our @jaumeortola

I am still developing the rule:

	<!-- 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...

Do you know where the error is?

Thanks!

It is fixed!

It had a special character in the suggestion.

Sorry for the trouble.

@rjlima

It is coded, but it has no hits in 600 000 sentences.

1 Like

@rjlima

Hello!

Can I also use “ou” and not just “e”?

Pareço um maluco com a barba grande OU com o cabelo grande.
→ Pareço um maluco com a barba OU o cabelo GRANDES.

If yes, the ending adjective is still plural, right (GRANDES)?

Thanks!

I hope that making the rule a bit more flexible will result in some hits in the 600 000 sentences.

Yes for both questions.