Skip to content

Commit

Permalink
[pt] Fix VIR_A_VERBO_VERBO
Browse files Browse the repository at this point in the history
  • Loading branch information
p-goulart committed Apr 9, 2024
1 parent a3b1408 commit 7e41e7c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public RuleMatch acceptRuleMatch(RuleMatch match, Map<String, String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16098,21 +16098,16 @@ USA
</rule>


<!-- VIR A VERBO verbo -->
<rule id='VIR_A_VERBO_VERBO' name="[Simplificar] Vir + a + Verbo → Verbo" type='style'>
<!--IDEA shorten_it-->
<!-- Created by Marco A.G.Pinto, Portuguese rule 2021-08-22 (25-JUN-2021+) -->
<!--
O nosso estudo terá grande aplicabilidade caso esta ameaça se venha a concretizar. → O nosso estudo terá grande aplicabilidade caso esta ameaça se concretize.
-->
<pattern>
<token inflected='yes'>vir<exception>vi</exception></token><!-- please remove "vi" as a form of "vir" from dict -->
<token>a</token>
<token postag='VMN.+' postag_regexp='yes'/>
</pattern>
<filter class="org.languagetool.rules.pt.AdvancedSynthesizerFilter" args="lemmaFrom:3 lemmaSelect:V.* postagFrom:1 postagSelect:V.*"/>
<filter class="org.languagetool.rules.pt.AdvancedSynthesizerFilter" args="lemmaFrom:3 lemmaSelect:V.+ postagFrom:1 postagSelect:V.+ postagReplace:keepPronoun"/>
<message>&simplify_msg;</message>
<example correction="concretize">O nosso estudo terá grande aplicabilidade caso esta ameaça se <marker>venha a concretizar</marker>.</example>
<example correction="especializar-se-ia">Acho que ele <marker>viria a especializar-se</marker> nisso.</example>
<example>Eu vi a professora Gómez ontem.</example>
<example>Quando eles vieram a receita quiseram fazer logo.</example>
</rule>
Expand Down Expand Up @@ -18244,6 +18239,10 @@ USA


<rulegroup id='VER_OBSERVAR_CONSTATAR' name="Ver → Observar/Constatar" type="style" tags="picky" tone_tags="academic" is_goal_specific="true">
<antipattern>
<token case_sensitive="yes">VI</token>
<example>Constantino VI no ano 790 da nossa era.</example>
</antipattern>
<antipattern>
<token inflected='yes' skip='-1'>ver</token>
<token regexp='yes'>filmes?|vídeos?|séries?|mensagem|mensagens|cenas?|televisão|tv|lado</token>
Expand Down

0 comments on commit 7e41e7c

Please sign in to comment.