From 7e41e7cbdf4a4f09f54a2fecca8a8ef0d578a3a9 Mon Sep 17 00:00:00 2001 From: p-goulart Date: Tue, 9 Apr 2024 16:23:40 +0200 Subject: [PATCH] [pt] Fix VIR_A_VERBO_VERBO --- .../AbstractAdvancedSynthesizerFilter.java | 2 +- .../rules/pt/AdvancedSynthesizerFilter.java | 25 +++++++++++++++++++ .../org/languagetool/rules/pt/style.xml | 13 +++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/languagetool-core/src/main/java/org/languagetool/rules/AbstractAdvancedSynthesizerFilter.java b/languagetool-core/src/main/java/org/languagetool/rules/AbstractAdvancedSynthesizerFilter.java index 54eb376162f1..4f53a5ee3163 100644 --- a/languagetool-core/src/main/java/org/languagetool/rules/AbstractAdvancedSynthesizerFilter.java +++ b/languagetool-core/src/main/java/org/languagetool/rules/AbstractAdvancedSynthesizerFilter.java @@ -163,7 +163,7 @@ public RuleMatch acceptRuleMatch(RuleMatch match, Map arguments, return match; } - private String getCompositePostag(String lemmaSelect, String postagSelect, String originalPostag, + public String getCompositePostag(String lemmaSelect, String postagSelect, String originalPostag, String desiredPostag, String postagReplace) { Pattern aPattern = Pattern.compile(lemmaSelect, Pattern.UNICODE_CASE); Pattern bPattern = Pattern.compile(postagSelect, Pattern.UNICODE_CASE); diff --git a/languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/AdvancedSynthesizerFilter.java b/languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/AdvancedSynthesizerFilter.java index 93d651bf3d7e..2975bb27ada1 100644 --- a/languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/AdvancedSynthesizerFilter.java +++ b/languagetool-language-modules/pt/src/main/java/org/languagetool/rules/pt/AdvancedSynthesizerFilter.java @@ -19,10 +19,17 @@ package org.languagetool.rules.pt; +import org.languagetool.AnalyzedTokenReadings; import org.languagetool.rules.AbstractAdvancedSynthesizerFilter; +import org.languagetool.rules.RuleMatch; import org.languagetool.synthesis.Synthesizer; import org.languagetool.synthesis.pt.PortugueseSynthesizer; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Objects; + /* * Synthesize suggestions using the lemma from one token (lemma_from) * and the POS tag from another one (postag_from). @@ -46,4 +53,22 @@ protected boolean isSuggestionException(String token, String desiredPostag) { return false; } + protected String movePronounTag(String sourceTag, String destinationTag) { + String[] sourceTagParts = sourceTag.split(":"); + String newTag = destinationTag; + if (sourceTagParts.length == 2) { + String[] destinationTagParts = destinationTag.split(":"); + newTag = destinationTagParts[0] + ":" + sourceTagParts[1]; + } + return newTag; + } + + @Override + public String getCompositePostag(String lemmaSelect, String postagSelect, String originalPostag, + String desiredPostag, String postagReplace) { + if (Objects.equals(postagReplace, "keepPronoun")) { + return movePronounTag(originalPostag, desiredPostag); + } + return super.getCompositePostag(lemmaSelect, postagSelect, originalPostag, desiredPostag, postagReplace); + } } \ No newline at end of file diff --git a/languagetool-language-modules/pt/src/main/resources/org/languagetool/rules/pt/style.xml b/languagetool-language-modules/pt/src/main/resources/org/languagetool/rules/pt/style.xml index 3a283bec05bf..84ce625daaf4 100644 --- a/languagetool-language-modules/pt/src/main/resources/org/languagetool/rules/pt/style.xml +++ b/languagetool-language-modules/pt/src/main/resources/org/languagetool/rules/pt/style.xml @@ -16098,21 +16098,16 @@ USA - - - - virvi a - + &simplify_msg; O nosso estudo terá grande aplicabilidade caso esta ameaça se venha a concretizar. + Acho que ele viria a especializar-se nisso. Eu vi a professora Gómez ontem. Quando eles vieram a receita quiseram fazer logo. @@ -18244,6 +18239,10 @@ USA + + VI + Constantino VI no ano 790 da nossa era. + ver filmes?|vídeos?|séries?|mensagem|mensagens|cenas?|televisão|tv|lado