// potentially slow (not using levenLimited) static Int mmo_levenWithSwapsScore_parsedPattern(MMOPattern pattern, S s) { S s2 = trim(s); if (pattern == null) null; if (startsWith(s2, "#")) null; // hashtags not handled here if (pattern cast MMOPattern.Phrase) { S p = pattern.phrase; if (startsWith(p, "#")) null; // hashtags not handled here if (endsWith(p, "!")) { if (!find3(p, s)) null; } else ret find3_levenWithSwapsDistance(p, s2); } if (pattern cast MMOPattern.And) { int score = 0; for (MMOPattern pat : pattern.l) { Int score2 = mmo_levenWithSwapsScore_parsedPattern(pat, s2); if (score2 == null) null; score += score2; } ret score; } if (pattern cast MMOPattern.Or) { Int min = null; for (MMOPattern pat : pattern.l) min = min_withNull(min, mmo_levenWithSwapsScore_parsedPattern(pat, s2)); ret min; } fail("what. " + pattern); }