// patterns = e.g. "Zitat, Anfrage, Preis, Kosten, Preise, Geld, wieviel, wie + viel" // potentially slow (not using levenLimited) static Int mmo_levenWithSwapsScore(S patterns, S s) { Int min = null; if (startsWith(s, "#")) null; patLoop: for (S pat : tok_splitAtComma(patterns)) { if (startsWith(pat, "#")) continue; // ignore special commands int score = 0; for (S phrase : tok_splitAtPlus(pat)) { if (endsWith(phrase, "!")) { if (!find3(phrase, s)) continue patLoop; } else { Int score2 = find3_levenWithSwapsDistance(phrase, s); if (score2 == null) continue patLoop; score += score2; } } min = min_withNull(min, score); } ret min; }