aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2022-01-06 04:19:36 +0100
committerache <ache@ache.one>2022-01-06 04:19:36 +0100
commit8d4fccb0127081da30eb7baa8ece7cae9176a370 (patch)
treeedc1eed1b62e4f8d91427c9d65001b51e0fb73be
parentAjout d'une correction orthographique (diff)
Génération de tous les chaînes à une certaine distance
-rwxr-xr-xdfr.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/dfr.py b/dfr.py
index 1ed5d40..3656c7e 100755
--- a/dfr.py
+++ b/dfr.py
@@ -67,6 +67,11 @@ def didYouMean(word):
memo[word[:i] + c + word[i:]] = True
yield word[:i] + c + word[i:]
+ # Insert at the end
+ for c in alpha:
+ memo[word + c] = True
+ yield word + c
+
for i in range(len(word)):
if word[:i] + word[i + 1:] not in memo:
memo[word[:i] + word[i + 1:]] = True