}
private RuleMatch createRuleMatch(AnalyzedTokenReadings tokenReadings, AnalyzedTokenReadings reqTokenReadings, List<String> posTagsToFind) {
String tokenString = tokenReadings.getToken();
Synthesizer ukrainianSynthesizer = ukrainian.getSynthesizer();
ArrayList<String> suggestions = new ArrayList<String>();
String oldPosTag = tokenReadings.getAnalyzedToken(0).getPOSTag();
String requiredPostTagsRegEx = ":(" + StringUtils.join(posTagsToFind,"|") + ")";
String posTag = oldPosTag.replaceFirst(":v_[a-z]+", requiredPostTagsRegEx);
// System.out.println(" creating suggestion for " + tokenReadings + " / " + tokenReadings.getAnalyzedToken(0) +" and tag " + posTag);
try {
String[] synthesized = ukrainianSynthesizer.synthesize(tokenReadings.getAnalyzedToken(0), posTag, true);
// System.out.println("Synthesized: " + Arrays.asList(synthesized));
suggestions.addAll( Arrays.asList(synthesized) );
} catch (IOException e) {
throw new RuntimeException(e);
}
ArrayList<String> reqVidminkyNames = new ArrayList<String>();
for (String vidm: posTagsToFind) {
reqVidminkyNames.add(UkrainianTagger.VIDMINKY_MAP.get(vidm));
}
ArrayList<String> foundVidminkyNames = new ArrayList<String>();
for(AnalyzedToken token: tokenReadings) {
String posTag2 = token.getPOSTag();
if( posTag2.contains(VIDMINOK_SUBSTR) ) {
foundVidminkyNames.add(UkrainianTagger.VIDMINKY_MAP.get(posTag2.replaceFirst("^.*"+VIDMINOK_REGEX+".*$", "$1")));
}
}
String msg = MessageFormat.format("Прийменник «{0}» вимагає іншого відмінка: {1}, а знайдено: {2}",
reqTokenReadings.getToken(), StringUtils.join(reqVidminkyNames, ", "), StringUtils.join(foundVidminkyNames, ", "));
if( tokenString.equals("їх") ) {
msg += ". Можливо тут потрібно присвійний займенник «їхній»?";
try {
String newYihPostag = "adj:p" + requiredPostTagsRegEx + ".*";
String[] synthesized = ukrainianSynthesizer.synthesize(new AnalyzedToken("їхній", "adj:m:v_naz:&pron", "їхній"), newYihPostag, true);
suggestions.addAll( Arrays.asList(synthesized) );
} catch (IOException e) {
throw new RuntimeException(e);
}
}