continue;
}
if (i > 0 && isSalutation(tokens[i-1].getToken())) { // e.g. "Frau Stieg" could be a name, ignore
continue;
}
final AnalyzedTokenReadings analyzedToken = tokens[i];
final String token = analyzedToken.getToken();
List<AnalyzedToken> readings = analyzedToken.getReadings();
boolean isBaseform = analyzedToken.getReadingsLength() >= 1 && analyzedToken.hasLemma(token);
if ((readings == null || analyzedToken.getAnalyzedToken(0).getPOSTag() == null || GermanHelper.hasReadingOfType(analyzedToken, GermanToken.POSType.VERB))
&& isBaseform) {
// no match, e.g. for "Groß": try if there's a match for the lowercased word:
AnalyzedTokenReadings lowercaseReadings = tagger.lookup(token.toLowerCase());
if (lowercaseReadings != null) {
readings = lowercaseReadings.getReadings();
}
boolean nextTokenIsPersonalPronoun = false;
if (i < tokens.length - 1) {
// avoid false alarm for "Das haben wir getan." etc:
nextTokenIsPersonalPronoun = tokens[i + 1].hasPartialPosTag("PRO:PER") || tokens[i + 1].getToken().equals("Sie");
}
potentiallyAddLowercaseMatch(ruleMatches, tokens[i], prevTokenIsDas, token, nextTokenIsPersonalPronoun);
}
prevTokenIsDas = nounIndicators.contains(tokens[i].getToken().toLowerCase());
if (readings == null) {
continue;
}
if (hasNounReading(analyzedToken)) { // it's the spell checker's task to check that nouns are uppercase
continue;
}
// TODO: this lookup should only happen once:
AnalyzedTokenReadings lowercaseReadings = tagger.lookup(token.toLowerCase());
if (analyzedToken.getAnalyzedToken(0).getPOSTag() == null && lowercaseReadings == null) {
continue;
}
if (analyzedToken.getAnalyzedToken(0).getPOSTag() == null && lowercaseReadings != null
&& lowercaseReadings.getAnalyzedToken(0).getPOSTag() == null) {
continue; // unknown word, probably a name etc
}
potentiallyAddUppercaseMatch(ruleMatches, tokens, i, analyzedToken, token);
}
return toRuleMatchArray(ruleMatches);