From 0d6822ee71c1f60c8003e13ab149501e586f9ae6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 8 Jun 2024 15:03:43 -0400 Subject: typo: Raise the insert/delete cost It should be at least half the max char distance so that we mostly get replacements, not inserts + deletes. --- src/typo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typo.c b/src/typo.c index b1c5c44..cb826fc 100644 --- a/src/typo.c +++ b/src/typo.c @@ -125,7 +125,7 @@ int typo_distance(const char *actual, const char *expected) { // This is the Wagner-Fischer algorithm for Levenshtein distance, using // Manhattan distance on the keyboard for individual characters. - const int insert_cost = 12; + const int insert_cost = (40 + 12 + 1) / 2; size_t rows = strlen(actual) + 1; size_t cols = strlen(expected) + 1; -- cgit v1.2.3