Search in sources :

Example 1 with AnalyzedGermanToken

use of org.languagetool.tagging.de.AnalyzedGermanToken in project languagetool by languagetool-org.

the class AgreementRule method getAgreementCategories.

/** Return Kasus, Numerus, Genus of those forms with a determiner. */
private Set<String> getAgreementCategories(AnalyzedTokenReadings aToken, Set<GrammarCategory> omit, boolean skipSol) {
    Set<String> set = new HashSet<>();
    List<AnalyzedToken> readings = aToken.getReadings();
    for (AnalyzedToken tmpReading : readings) {
        if (skipSol && tmpReading.getPOSTag() != null && tmpReading.getPOSTag().endsWith(":SOL")) {
            // SOL = alleinstehend - needs to be skipped so we find errors like "An der roter Ampel."
            continue;
        }
        AnalyzedGermanToken reading = new AnalyzedGermanToken(tmpReading);
        if (reading.getCasus() == null && reading.getNumerus() == null && reading.getGenus() == null) {
            continue;
        }
        if (reading.getGenus() == GermanToken.Genus.ALLGEMEIN && tmpReading.getPOSTag() != null && // STV: stellvertretend (!= begleitend)
        !tmpReading.getPOSTag().endsWith(":STV") && !possessiveSpecialCase(aToken, tmpReading)) {
            // e.g. "Ich Arbeiter" doesn't get flagged as incorrect:
            if (reading.getDetermination() == null) {
                // Nouns don't have the determination property (definite/indefinite), and as we don't want to
                // introduce a special case for that, we just pretend they always fulfill both properties:
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.MASKULINUM, GermanToken.Determination.DEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.MASKULINUM, GermanToken.Determination.INDEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.FEMININUM, GermanToken.Determination.DEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.FEMININUM, GermanToken.Determination.INDEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.NEUTRUM, GermanToken.Determination.DEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.NEUTRUM, GermanToken.Determination.INDEFINITE, omit));
            } else {
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.MASKULINUM, reading.getDetermination(), omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.FEMININUM, reading.getDetermination(), omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), GermanToken.Genus.NEUTRUM, reading.getDetermination(), omit));
            }
        } else {
            if (reading.getDetermination() == null || "jed".equals(tmpReading.getLemma()) || "manch".equals(tmpReading.getLemma())) {
                // "jeder" etc. needs a special case to avoid false alarm
                set.add(makeString(reading.getCasus(), reading.getNumerus(), reading.getGenus(), GermanToken.Determination.DEFINITE, omit));
                set.add(makeString(reading.getCasus(), reading.getNumerus(), reading.getGenus(), GermanToken.Determination.INDEFINITE, omit));
            } else {
                set.add(makeString(reading.getCasus(), reading.getNumerus(), reading.getGenus(), reading.getDetermination(), omit));
            }
        }
    }
    return set;
}
Also used : AnalyzedToken(org.languagetool.AnalyzedToken) AnalyzedGermanToken(org.languagetool.tagging.de.AnalyzedGermanToken)

Aggregations

AnalyzedToken (org.languagetool.AnalyzedToken)1 AnalyzedGermanToken (org.languagetool.tagging.de.AnalyzedGermanToken)1