diff --git a/src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/Levenshtein.kt b/src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/Levenshtein.kt index 0d203c1d..827f4a24 100644 --- a/src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/Levenshtein.kt +++ b/src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/Levenshtein.kt @@ -244,7 +244,7 @@ fun CFG.hasSingleEditRepair(tokens: List, range: IntRange): Boolean = val rangeSub = (maxOf(0, range.first) until minOf(tokens.size, range.last + 1)) val rangeIns = (maxOf(0, range.first) until minOf(tokens.size + 1, range.last + 2)) rangeSub.any { i -> toCheck.mapIndexed { j, t -> if (j == i) "_" else t } in language } // Check substitutions - && rangeIns.any { (toCheck.take(it) + "_" + toCheck.drop(it)) in language } // Check insertions + || rangeIns.any { (toCheck.take(it) + "_" + toCheck.drop(it)) in language } // Check insertions } // Tries to shrink a multi-edit range until it has a single edit repair