From 20424c4ad7166a9683de812cab5eed6f8f3425fc Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Mon, 20 Mar 2017 16:59:12 +0000 Subject: Make the spell checker a bit more conservative. Reduce the max spell-checking distance for matching words. "target" will not match "range" anymore. -- PiperOrigin-RevId: 150638073 MOS_MIGRATED_REVID=150638073 --- src/main/java/com/google/devtools/build/lib/util/SpellChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/com/google/devtools/build/lib/util') diff --git a/src/main/java/com/google/devtools/build/lib/util/SpellChecker.java b/src/main/java/com/google/devtools/build/lib/util/SpellChecker.java index 2671a90590..ba3ae189be 100644 --- a/src/main/java/com/google/devtools/build/lib/util/SpellChecker.java +++ b/src/main/java/com/google/devtools/build/lib/util/SpellChecker.java @@ -83,7 +83,7 @@ public final class SpellChecker { public static String suggest(String input, Iterable words) { String best = null; // Heuristic: the expected number of typos depends on the length of the word. - int bestDistance = Math.min(5, input.length() / 2 + 1); + int bestDistance = Math.min(5, (input.length() + 1) / 2); input = input.toLowerCase(); for (String candidate : words) { int d = editDistance(input, candidate.toLowerCase(), bestDistance); -- cgit v1.2.3