languagetool-org / languagetool

Style and Grammar Checker for 25+ Languages
https://languagetool.org
GNU Lesser General Public License v2.1
12.01k stars 1.38k forks source link

[pt] Gender agreement issues #6773

Open ricardojosehlima opened 2 years ago

ricardojosehlima commented 2 years ago

Hi, The following gender mismatches between a determiner/pronoun masculine and a feminine noun are flagged: Eu comprei esse mesa. Eu li o revista.

However, the inverse is not: Eu comprei essa carro. Eu li a livro.

In a similar way, but it may be a different rule, the expression 'a meu ver' is licensed in LT, but 'a nosso ver' is not - it is flagged for 'o nosso', and should be 'a nosso ver'.

marcoagpinto commented 2 years ago

Ahhhhh… thanks for spotting it.

The gender agreement rules have tons of antipatterns, which I started coding years ago when I didn't have much knowledge compared to today.

Right now, I don't have the chance, but tonight or at 5am I will find if one of the antipatterns is removing the hit.

Thanks!

marcoagpinto commented 2 years ago

@ricardojosehlima

I was looking at the antipatterns, and they are a mess, I can't spot which one causes the issue.

I will have to fix them little by little.

I was seeing the POS information for: Eu li a livro. and it appears as: PP1CSN00 + NCMS000 + SPS00 + NCMS000

"li" isn't tagged also as a verb.

I have just tagged it, and I am about to see the difference in 600 000 sentences.

This would probably fix tons of false positives.

marcoagpinto commented 2 years ago

@jaumeortola

Jaume, I am going to need your help.

Even adding the POS to the added.txt, in trunk, snapshot and Wikipedia, the standalone tool still tags "li" as a noun:

Já li o livro.
Eu li o livro.

https://github.com/languagetool-org/languagetool/commit/8eb2e60c72650fea73ca175871c8b57284f45740

What could be wrong?

Thanks!

marcoagpinto commented 2 years ago

@jaumeortola

It is very strange… the standalone tool also says that: "li." is a noun, even with the changes I made in added.txt.

marcoagpinto commented 2 years ago

@ricardojosehlima

I have done some clean-up in the GENDER rules (antipatterns), but there is still a long way to go: https://github.com/languagetool-org/languagetool/commit/ba5216bdcd60c80740598392aba9a5f8dff1d026

jaumeortola commented 2 years ago

The disambiguation rule RARE_POS[1] always removed the tag VMIS1S0 from "li". I changed this rule. https://github.com/languagetool-org/languagetool/commit/f5819ed09f952b2d319ca98c82e2eabf8a35f915 There could be some undesired effects for "li" in other contexts, and perhaps we need other disambiguation rules.

marcoagpinto commented 2 years ago

@jaumeortola

The "li” POS was a huge success according to the night results.

It is a very common word in Portuguese: “I read the book!” → “Eu li o livro!”

ricardojosehlima commented 2 years ago

Great! @marcoagpinto mentioned many antipatterns to look at, maybe there is something I could help.

marcoagpinto commented 2 years ago

The antipatterns will give a ton of work.

First I must generate the hits against 600 000 sentences.

Then, one by one, I add something like: <token>falseword</token> and check again 600 000 sentences to see if the antipattern is no longer used or if it gives some false positives.

It will take some time to check them all

ricardojosehlima commented 2 years ago

Ok! But it doesn't seem something specific to a word or a verb, I tested it with many words and verbs, or is there some sort of list?

marcoagpinto commented 2 years ago

Here is an example which I can't remember if it is for male or female:

<!-- MARCOAGPINTO 2020-05-22 *START* -->
<!-- "Edificações erguidas por arquitetos índios centenas de anos antes da conquista europeia." -->
<!-- "Surgiram no reino centenas de pequenas habitações." -->
      <antipattern>
          <token postag='NCM[SP]000' postag_regexp='yes'/>
          <token postag='Z0FP0' postag_regexp='no'/>
          <token postag='SPS00' postag_regexp='no'/>              
      </antipattern>    
<!-- MARCOAGPINTO 2020-05-22 *END* -->
<!-- MARCOAGPINTO 2020-07-04 (2-JUL-2020+) *START* -->
<!-- "O Rui aprende e sugere ele próprio mensagens como sendo verdadeiras." -->
<!-- "O Rui aprende e sugere ele mesmo mensagens como sendo verdadeiras." -->
      <antipattern>
          <token regexp='yes'>ao|com|de|do|e|ele|em|esse|este|mais|menos|nesse|no|o|ou|por|que|seu</token>    
          <token postag='NCMS000' postag_regexp='no'/>      
          <token postag='NC[CFM]P000' postag_regexp='yes'/>
      </antipattern>  
      <antipattern>
          <token postag='V.+|RG' postag_regexp='yes'/> 
          <token postag='NCMS000' postag_regexp='no'/>      
          <token postag='NC[CFM]P000' postag_regexp='yes'/>
      </antipattern>      
<!-- MARCOAGPINTO 2020-07-04 (2-JUL-2020+) *END* -->
<!-- MARCOAGPINTO 2020-07-30 (2-JUL-2020+) *START* -->
<!-- "Uma informação o mais simples e o mais rica." -->
      <antipattern>
          <token postag='DA0MS0|PD0MS000|PP3MSA00' postag_regexp='yes'/>          
          <token postag='NC[CM]S000|NC[CM]N000|RG' postag_regexp='yes'/>
          <token postag='AQ0[CF]S0|NC[CF]S000' postag_regexp='yes'/>
          <token negate="yes" regexp='yes'>em|da|do|que</token>
      </antipattern>    
<!-- MARCOAGPINTO 2020-07-30 (2-JUL-2020+) *END* -->

<!-- MARCOAGPINTO 2020-08-18 (2-JUL-2020+) *START* -->
<!-- "Uma máquina a motor mais pesada que o ar." -->
<!-- "Uma máquina a gasolina mais pesada que o ar." -->
<!-- "A entrar no Império tão grande quantidade de escravos africanos." -->
      <antipattern>
        <token postag='V.+|NC[CFM]S000|AQ0[CFM]S0|CS|I|PT0CN000|RG' postag_regexp='yes'/>
        <token regexp='yes'>a|ao|no|do|se|de|muito|pouco|cada|para|grande|pequeno|maior|menor</token>
        <token postag='AQ0[CFM]S0|NC[CFM]S000' postag_regexp='yes'/>
        <token postag='NC[CM]S000|NC[CM]N000|RG' postag_regexp='yes'/>
        <token postag='NC[CF]S000|AQ0[CF]S0|VMP00SF' postag_regexp='yes'/>
      </antipattern>      
<!-- MARCOAGPINTO 2020-08-18 (2-JUL-2020+) *END* -->

<!-- MARCOAGPINTO 2020-09-14 (2-JUL-2020+) *START* -->
<!-- "Não devia ser necessário petições para legalizar a profissão." -->
      <antipattern>
          <token postag='V.+|NC[CM]S000|CS|I|RG|VMP00SM' postag_regexp='yes'/>
          <token postag='AQ0[CM]S0|NC[CF]S000' postag_regexp='yes'/>
          <token postag='NC[CF]P000' postag_regexp='yes'/>
      </antipattern>              
      <!-- "Suspeita-se que tenham, em escalas de tempo, levado quantidades significativas de água." -->
      <antipattern>
          <token regexp='yes'>[,]|de|e</token>
          <token postag='AQ0[CM]S0|NC[CF]S000' postag_regexp='yes'/>
          <token postag='NC[CF]P000' postag_regexp='yes'/>
      </antipattern>          
<!-- MARCOAGPINTO 2020-09-14 (2-JUL-2020+) *END* -->

<!-- MARCOAGPINTO 2020-10-27 (21-OCT-2020+) *START* -->
<!-- "Precisa agora de estar em quarentena 1 dia." -->
<!-- "Precisa agora de estar em quarentena 14 dias." -->
<!-- "Precisa agora de estar em quarentena 14 horas." -->
<!-- "Precisa agora de estar em plantão 14 horas." -->
      <antipattern>
          <token postag='NC[CFM]S000' postag_regexp='yes'/>
          <token postag='Z0CN0'></token>
          <token postag='AQ0[CFM][SP]0|NC[CFM][SP]000' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2020-10-27 (21-OCT-2020+) *END* -->

<!-- MARCOAGPINTO 2021-01-16 (1-JAN-2021+) *START* -->
<!--
ao princípio Mãe.
o princípio Mãe.
pelo princípio Mãe.
do princípio Mãe.
um princípio Mãe.
esse princípio Mãe.
aquele princípio Mãe.
àquele princípio Mãe.
tal princípio Mãe.
como princípio Mãe.
no princípio Mãe.
daquele princípio Mãe.
e princípio Mãe.
-->
      <antipattern>     
        <token regexp='yes'>a?o|pelo|do|um|esse|aquele|àquele|tal|como|no|daquele|e</token>
        <token regexp='no'>princípio</token>
        <token postag='NC.S.+|AQ0.S.+|NP.+' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2021-01-16 (1-JAN-2021+) *END* -->

<!-- MARCOAGPINTO 2021-02-22 (1-JAN-2021+) *START* -->
<!--
O que o torna mais perigoso é haver civis inocentes.
O que o torna perigoso é haver civis inocentes.
-->
      <antipattern>
        <token negate_pos="yes" postag='SENT_START' postag_regexp='no'/>
        <token postag='DA0MS0' postag_regexp='no'/>
        <token postag='NCFS000' postag_regexp='no'/>
        <token min="0" max="1" postag='RG' postag_regexp='no'/>
        <token postag='AQ0MS0' postag_regexp='no'/>
      </antipattern> 
<!-- MARCOAGPINTO 2021-02-22 (1-JAN-2021+) *END* -->

<!-- MARCOAGPINTO 2021-04-13 (17-MAR-2021+) *START* -->
<!--
No ponto borboleta, as diferentes superfícies são importantes.
Não traduza inglês para japonês palavra por palavra.
Eu comecei a aprender chinês semana passada.
Eu gosto de comer comida coreana.
Não tenho nenhum interesse em comer comida inglesa.
A medicina é uma das muitas áreas do conhecimento ligada à manutenção e restauração da saúde.
-->
      <antipattern>
        <token negate="yes" regexp='yes'>o|um</token>
        <token postag='NCMS000|AQ0MS0' postag_regexp='yes'/>
        <token postag='NCFS000|AQ0FS0' postag_regexp='yes'/>
      </antipattern>
      <antipattern>
        <token regexp='yes'>o|um</token>
        <token postag='NCMS000|AQ0MS0' postag_regexp='yes'/>
        <token postag='NCFS000|AQ0FS0' postag_regexp='yes'/>
        <token negate="yes" regexp='yes'>[.,!?;():]</token>
      </antipattern>      
<!-- MARCOAGPINTO 2021-04-13 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-04-15 (17-MAR-2021+) *START* -->
<!--
Autentifique-se com a sua conta LanguageTool.
Autentifique-se com o seu cartão MUFON.
Em resposta, a administração Bush lançou uma "Guerra ao Terror".
A bacia Beethoven tem um tamanho similar de material ejetado e uma borda de 625 km de diâmetro.
Durante a dinastia Ming (no início do século XV) havia a Cidade Proibida no centro de Pequim.
A própria Jane escreveu a carta.
-->
      <antipattern>
        <token postag='DP.F.+|DI.F.+|DD.F.+|AQ0C.+' postag_regexp='yes'/>
        <token postag='NCF.+|AQ0F.+' postag_regexp='yes'/>
        <token postag='NP.+' postag_regexp='yes'/>
      </antipattern>
      <antipattern>
        <token regexp='yes'>[.,!?;():]|à|as?|das?|destas?|pelas?|em|nas?</token>
        <token postag='NCF.+|AQ0F.+' postag_regexp='yes'/>
        <token postag='NP.+' postag_regexp='yes'/>
      </antipattern>      
      <antipattern>
        <token postag='DP.M.+|DI.M.+|DD.M.+|AQ0C.+' postag_regexp='yes'/>
        <token postag='NCM.+|AQ0M.+' postag_regexp='yes'/>
        <token postag='NP.+' postag_regexp='yes'/>
      </antipattern>
      <antipattern>
        <token regexp='yes'>[.,!?;():]|os?|dos?|destes?|pelos?|em|nos?</token>
        <token postag='NCM.+|AQ0M.+' postag_regexp='yes'/>
        <token postag='NP.+' postag_regexp='yes'/>
      </antipattern>      
<!-- MARCOAGPINTO 2021-04-15 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-05-26 (17-MAR-2021+) *START* -->
<!--
O meu pai inúmeras vezes dá o exemplo.
Vi um várias vezes.
Ele tem dificuldade para comer comidas novas.
Tom fugiu do cativeiro diversas vezes.
Água, erosão e controle da poluição têm se tornado questões importantes nas relações da China com outros países.
-->
      <antipattern>
          <token postag='AQ0FP0|NCFP000' postag_regexp='yes'/>
          <token postag='AQ0FP0|NCFP000' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2021-05-26 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-05-26 (17-MAR-2021+) *START* -->
<!--
As insurgências no mundo islâmico causadas pela revolta.
Minhas caixinhas de som são um brinquedo comparadas com as suas.
São as seguintes unidades de conservação a nível federal localizadas em Mato Grosso.
-->
      <antipattern> 
          <token postag='NC.S.+|AQ0.S.+' postag_regexp='yes'/>
          <token postag='V....P.+' postag_regexp='yes'/>
          <token postag='SPS.+' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2021-05-26 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-06-03 (17-MAR-2021+) *START* -->
<!--
As insurgências no mundo islâmico causadas pela população.
Hoje, a Ericeira continua a ser uma das zonas do litoral do país mais procuradas para banhos.
A batalha durou pouco, tendo sofrido o exército castelhano pesadas baixas.
As concepções do belo de Aristóteles ficam por um longo período esquecidas, sendo somente retomadas ao final da Idade Média.
-->
      <antipattern>
        <token postag='NCM.+|AQ0M.+' postag_regexp='yes'/>
        <token postag='NCM.+|AQ0M.+' postag_regexp='yes'/>
        <token postag='V.+' postag_regexp='yes'/>
        <token negate_pos="yes" postag='DI.+|DA.+|Z0.+' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2021-06-03 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-06-18 (17-MAR-2021+) *START* -->
<!--
Até esse humano multiplicado inúmeras vezes.
São artes marciais que incluem tanto golpes de combate em pé quanto técnicas de luta no chão.
O género Bacterium compreendia bactérias com formato de bastão não formadoras de esporos.
-->
      <antipattern>
        <token postag='AQ0M.+|NCM.+' postag_regexp='yes'/>
        <token postag='V.....M|AQ0M.+|NCM.+' postag_regexp='yes'/>
        <token postag='AQ0F.+|NCF.+' postag_regexp='yes'/>
      </antipattern>
<!-- MARCOAGPINTO 2021-06-18 (17-MAR-2021+) *END* -->
<!-- MARCOAGPINTO 2021-08-17 (25-JUN-2021+) *START* -->
<!--
Tive minhas primeiras experiências sexuais com uma mulher vários anos mais velha que eu.
Em outra publicação sua no mesmo ano, Einstein pôs em dúvida vários princípios do eletromagnetismo clássico.
-->
      <antipattern>
        <token/>
        <token regexp='yes'>vários?</token>
        <token postag='AQ0[CM].+|NC[CM].+' postag_regexp='yes'/>
      </antipattern>
<!--
Como incentivo a este tipo de música, a Câmara Municipal de Braga criou no estádio 1.º de Maio várias salas de ensaio.
Série 9xx Cada série foca um determinado mercado, possuindo os aparelhos várias semelhanças entre si.
-->
      <antipattern>
        <token/>
        <token regexp='yes'>várias?</token>
        <token postag='AQ0[CF].+|NC[CF].+' postag_regexp='yes'/>
      </antipattern>      
<!-- MARCOAGPINTO 2021-08-17 (25-JUN-2021+) *END* -->

<!-- MARCOAGPINTO 2022-06-05/11 (5-JUN-2022+) *START* -->
      <antipattern>
        <token postag='[DP][ADIP].[NF].+|SPS00:[DP][ADIP].[NF].+' postag_regexp='yes'/>
        <token postag='AQ.[CF].+|NC[CF].+' postag_regexp='yes'/>
        <token postag='SPS.+' postag_regexp='yes'/>
        <token postag='AQ.+|NC.+' postag_regexp='yes'/>
        <token postag='SPS.+' postag_regexp='yes'/> 
        <token postag='AQ.+|NC.+' postag_regexp='yes'/>
        <token min="0" max="1" postag='RM' postag_regexp='no'/>
        <token postag='VMP00.F|AQ.[CF].+|NC[CF].+' postag_regexp='yes'/>
        <example>...ísica abre: Para as compras realizadas nestes dias, as regras de entrega são as mesmas de segunda a sábado descritas acima.</example>
        <example>Isto tendo em conta as técnicas de engenharia de software mundialmente estabelecidas.</example>
      </antipattern>
<!-- MARCOAGPINTO 2022-06-05/11 (5-JUN-2022+) *END* -->

<!-- MARCOAGPINTO 2022-06-11 (Checked/Enhanced) (5-JUN-2022+) *START* -->
      <antipattern>
        <token postag='[DP]..[MN].+|V.+|Z0[MN].+|SPS.+|CC|CS|RG' postag_regexp='yes'/>
        <token min="1" max="2" postag='AQ.[CM].+|NC[CM].+' postag_regexp='yes'/>
        <token postag='NP.+' postag_regexp='yes'/>
        <example>Com a marca, um <marker>exclusivo Auchan</marker>.</example>
        <example>Um computador da Dell pode ser integrado com um processador Intel.</example>
        <example>Uma cliente disse querer pagar com o cartão Auchan.</example>
        <example>Os clientes dizem ter cartão Auchan.</example>
        <example>O navio português Santa Catarina foi capturado pela Companhia da Índia holandesa.</example>
        <example>Vale lembrar que o guia Europa de Cinema está cheio de dicas interessantíssimas de Londres.</example>
      </antipattern>
<!-- MARCOAGPINTO 2022-06-11 (Checked/Enhanced) (5-JUN-2022+) *END* -->
marcoagpinto commented 2 years ago

And this mess is only for one gender, then I need to check for the other gender.

It will take weeks to fix and improve the antipatterns.

Years ago, I didn't have the proper knowledge yet.

ricardojosehlima commented 2 years ago

Wow, that's really a lot! Hope you can figure it out sooner than expected!

marcoagpinto commented 2 years ago

@ricardojosehlima

I have been working on it, I discovered that I wanted also to use neutral in nouns and such, and it was causing false positives.

<token postag='AQ.[CF].+|NC[CF].+' postag_regexp='yes'/>

I am going to recheck the antipatterns I created days ago.

Meanwhile, I can't commit right now since my “em suma” rule from yesterday broke the build and Udomai reverted it.

There is a bug in the core of LanguageTool, and I am waiting for someone to say when it is fixed so that I can commit again.

marcoagpinto commented 2 years ago

Ahhhh... I am still making some tests with the [CF] and it may well work after all.

marcoagpinto commented 2 years ago

@ricardojosehlima

I have been working on it.

Currently, I am replacing an antipattern that caused tons of false positives.

The sentences are now flagged:

Eu comprei esse mesa.
Eu li o revista.

I am just waiting for @udomai to say that the core is fixed so that I can commit the last rule again plus the antipatterns for gender.

Ricardo, notice that it will take several weeks or even months to fix all the antipatterns.

marcoagpinto commented 2 years ago

@ricardojosehlima

I have recommitted the “em suma” rule plus tons of gender fixes in the antipatterns (WIP): https://github.com/languagetool-org/languagetool/commit/11e47b858a61d0faf64129f02efe22ae5fd95cb2

Thanks!

marcoagpinto commented 2 years ago

@ricardojosehlima

I have fixed some more gender antipatterns: https://github.com/languagetool-org/languagetool/commit/ff8e9426110c617e33bee279db211982e805f7a2

marcoagpinto commented 2 years ago

@ricardojosehlima

A few more fixes: https://github.com/languagetool-org/languagetool/commit/23efcdc73d3398480bc282911a8540473bf71c6a

ricardojosehlima commented 2 years ago

Ok @marcoagpinto thanks! I've been away for some time due to many things happening at the same time here, plus a holiday in Brazil. This week I'll be able to participate more.

marcoagpinto commented 2 years ago

@ricardojosehlima

I have been fixing the gender antipatterns.

https://github.com/languagetool-org/languagetool/commit/ef6a64fe30fdf71377ec1f5d7c8d21eed2474272

I scrolled down the grammar.xml and noticed that the gender rulegroup has many rules, and the rules have tons of antipatterns created by me…

It will take months to check them one by one.

Tuesday or Wednesday is the official LanguageTool release, and I will do a few more fixes before it.