if (isPhraseImpersonalVerbS(tokens, i) )
continue loop;
// the rule matches
final String msg = "Expressió incorrecta si equival a 'adonar-se', correcta si vol dir 'retre compte'.";
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i].getStartPos(), tokens[i].getStartPos()
+ token.length(), msg,
"Possible error");
ruleMatches.add(ruleMatch);
}
// Comprova: portar-se/emportar-se
if (i+2<tokens.length
&& matchLemmaRegexp(tokens[i], VERBS_PORTAR_DUR)
&& ! (matchPostagRegexp(tokens[i], VERB_INF) && isThereBefore(tokens,i,LEMMA_PREP_A_PER,POSTAG_PREPOSICIO))
&& !hasVerbMultipleReadings(tokens[i]) //em duràs un mocador
&& isThereReflexivePronoun(tokens, i) // ens portem, ens hem de portar
&& isThereAfterWithoutPreposition(tokens, i, POSTAG_CD)
&& !isThereVerbBefore(tokens,i,VERBS_DEIXAR_FER) // es deixen portar
&& !(isThereVerbBefore(tokens,i,VERBS_POTENCIALMENT_PRONOMINALS)&&!isThereVerbBefore(tokens,i,NO_VERBS_POTENCIALMENT_PRONOMINALS))
&& !matchPostagRegexp(tokens[i+1], POSTAG_ADVERBI) // es porten bé
&& !matchPostagRegexp(tokens[i+2], POSTAG_ADVERBI) // hem de portar-nos bé
&& !matchLemmaRegexp(tokens[i+2], ANYMESDIA) // ens portem tres anys
&& !isPhraseImpersonalVerbSP(tokens, i) // Es va portar l'any passat
) {
// the rule matches
String suggestion;
if (matchLemmaRegexp(tokens[i], VERB_PORTAR)) {suggestion= "em"+token; }
else if (token.equalsIgnoreCase("du")) {suggestion="endú"; }
else {suggestion= "en"+token; }
final String msg="¿Volíeu dir <suggestion>"+suggestion+"</suggestion>?";
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i].getStartPos(), tokens[i].getStartPos()
+ token.length(), msg, "Possible error");
ruleMatches.add(ruleMatch);
continue loop;
}
//PERÍFRASI AMB VERB PRONOMINAL: el fan *agenollar-se/agenollar
if (i+1<tokens.length
&& matchPostagRegexp(tokens[i], VERB_INF)
&& !matchPostagRegexp(tokens[i - 1], POSTAG_PREPOSICIO)
&& isThereVerbBefore(tokens,i,VERBS_DEIXAR_FER)
&& isThereBefore(tokens, i, LEMMA_PRONOM_CD, POSTAG_PRONOM_CD)
&& matchRegexp(tokens[i + 1].getToken(), REFLEXIU_POSPOSAT) ) {
// the rule matches
final String msg = "En aquesta perífrasi verbal el pronom reflexiu posterior és redundant.";
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i+1].getStartPos(), tokens[i+1].getStartPos()
+ tokens[i+1].getToken().length(), msg, "Pronom redundant");
ruleMatches.add(ruleMatch);
continue loop;
}
//VERBS PRONOMINALS: Cal que hi hagi pronom reflexiu.
if (matchLemmaRegexp(tokens[i], VERBS_PRONOMINALS)) {
if (matchLemmaRegexp(tokens[i], NO_VERBS_PRONOMINALS))
// atengué l'administració
continue loop;
if (matchPostagRegexp(tokens[i], VERB_PARTICIPI) && !matchLemmaRegexp(tokens[i - 1], VERB_HAVER))
continue loop;
if (isThereVerbBefore(tokens,i,VERBS_DEIXAR_FER) // el fa agenollar
&& isThereBefore(tokens, i, LEMMA_PRONOM_CD, POSTAG_PRONOM_CD) )
continue loop;
if (isThereReflexivePronoun(tokens, i))
continue loop;
// the rule matches
final String msg = "Aquest verb és pronominal. Probablement falta un pronom.";
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i].getStartPos(), tokens[i].getStartPos()
+ token.length(), msg,
"Verb pronominal: falta un pronom");
ruleMatches.add(ruleMatch);
continue loop;
}
//VERBS NO PRONOMINALS: No hi ha d'haver pronom reflexiu.
if (matchLemmaRegexp(tokens[i], VERBS_NO_PRONOMINALS)) {
if (matchLemmaRegexp(tokens[i], NO_VERBS_NO_PRONOMINALS))
continue loop;
if (!isThereReflexivePronoun(tokens, i))
continue loop;
//impersonal obligació: s'ha de baixar
if (matchLemmaRegexp(tokens[i],VERBS_NO_PRONOMINALS_IMPERSONALS2)
&& isThereBefore(tokens, i, LEMMA_ES, POSTAG_ES)
&& isThereBefore(tokens, i, LEMMA_DE, POSTAG_DE)
&& isThereVerbBefore(tokens,i,VERB_HAVER) )
continue loop;
if (isThereVerbBefore(tokens,i,VERBS_SOVINT_AMB_COMPLEMENT)
|| (isThereVerbBefore(tokens,i,VERBS_POTENCIALMENT_PRONOMINALS)&&!isThereVerbBefore(tokens,i,NO_VERBS_POTENCIALMENT_PRONOMINALS))
|| isThereVerbBefore(tokens,i,VERBS_PRONOMINALS)) //et deixes caure, et fas témer,
continue loop;
//FRASE IMPERSONAL
// És frase impersonal si hi ha el pronom 'es', llevat que es pugui identificar un subjecte "personal"
if (matchLemmaRegexp(tokens[i],VERBS_NO_PRONOMINALS_IMPERSONALS)
&& isPhraseImpersonalVerbS(tokens, i) )
continue loop;
if (matchLemmaRegexp(tokens[i],VERBS_NO_PRONOMINALS_IMPERSONALS2)
&& isPhraseImpersonalVerbSP(tokens, i) )
continue loop;
// the rule matches
final String msg = "Aquest verb no és pronominal. Probablement sobra un pronom.";
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i].getStartPos(), tokens[i].getStartPos()
+ token.length(), msg,
"Verb no pronominal");
ruleMatches.add(ruleMatch);
}
//VERBS DE MOVIMENT: si hi ha pronom reflexiu cal el pronom 'en'.
if (matchLemmaRegexp(tokens[i], VERBS_MOVIMENT) && !matchPostagRegexp(tokens[i], VERB_AUXILIAR)) {
if (matchLemmaRegexp(tokens[i], VERBS_NO_MOVIMENT))
// atengué l'administració
continue loop;
//impersonal obligació: s'ha de baixar
if (isThereBefore(tokens, i, LEMMA_ES, POSTAG_ES)
&& isThereBefore(tokens, i, LEMMA_DE, POSTAG_DE)
&& isThereVerbBefore(tokens,i,VERB_HAVER) )
continue loop;
if (isThereVerbBefore(tokens,i,VERBS_SOVINT_AMB_COMPLEMENT)
|| (isThereVerbBefore(tokens,i,VERBS_POTENCIALMENT_PRONOMINALS)&&!isThereVerbBefore(tokens,i,NO_VERBS_POTENCIALMENT_PRONOMINALS))
|| isThereVerbBefore(tokens,i,VERBS_PRONOMINALS) //et deixes anar/pujar
|| isThereVerbAfter(tokens,i,VERBS_SOVINT_AMB_COMPLEMENT) ) // per venir-vos a veure
continue loop;
if (matchLemmaRegexp(tokens[i], VERB_VENIR)) {
if (isThereAfter(tokens, i, VERB_INF))
continue loop;
}
if (matchLemmaRegexp(tokens[i], VERB_ANAR)) {
if (isThereAfter(tokens, i, VERB_GERUNDI))
continue loop;
if (isThereVerbAfter(tokens, i,
VERBS_POTENCIALMENT_PRONOMINALS)
||isThereVerbAfter(tokens,i,VERBS_PRONOMINALS))
continue loop;
if (hasVerbMultipleReadings(tokens[i]) && isThereAfter(tokens,i,POSTAG_ADVERBI))
continue loop;
//FRASE IMPERSONAL
if (isThereBefore(tokens, i, LEMMA_ES, POSTAG_ES)
&& !isThereBefore(tokens, i, LEMMA_PRONOM_CI, POSTAG_PRONOM_CI)
&& (!isTherePersonalSubjectBefore(tokens,i,TRENCA_COMPTE) || isThereBefore(tokens, i, LEMMA_HI, POSTAG_HI))
&& isVerbNumberPerson(tokens,i,VERB_3S))
continue loop;
}
else {
// FRASE IMPERSONAL
if (isThereBefore(tokens, i, LEMMA_ES, POSTAG_ES)
&& !isThereBefore(tokens, i, LEMMA_PRONOM_CI, POSTAG_PRONOM_CI)
&& !isTherePersonalSubjectBefore(tokens, i, TRENCA_COMPTE))
continue loop;
}
if (isThereReflexivePronoun(tokens, i) && (!isTherePronoun(tokens, i, LEMMA_EN, POSTAG_EN))) {
// the rule matches
final String msg = "No useu com a pronominal aquest verb, o bé afegiu-hi el pronom 'en'."; //Cal canviar el missatge
final RuleMatch ruleMatch = new RuleMatch(this,
tokens[i].getStartPos(), tokens[i].getStartPos()
+ token.length(), msg,
"Falta el pronom 'en'");
ruleMatches.add(ruleMatch);
}