We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 640c793 commit 12be302Copy full SHA for 12be302
1 file changed
back5/src/back5/spell.clj
@@ -17,17 +17,21 @@
17
(str (apply str (take i word)) (apply str (drop (inc i) word))))
18
19
(defn deletes [word]
20
+ (into {}
21
(for [x (range (.length word))]
- {(without-char word x) 1}))
22
+ [(without-char word x) 1])))
23
24
(defn edits1 [word]
25
(let [s (for [i (range (inc (count word)))] (split-at i word))
26
deletes (deletes word)
- transposes (for [[a,b] s :when (> (count b) 1)]
27
- (concat a [(second b)] [(first b)] (drop 2 b)))
+ transposes (into {}
28
+ (for [[a,b] s :when (> (count b) 1)]
29
+ [(apply str
30
+ (concat a [(second b)] [(first b)] (drop 2 b)))
31
+ 1]))
32
replaces []
33
inserts [] ]
- (zipmap (concat deletes transposes replaces inserts) (repeat 1))))
34
+ (merge-with max deletes transposes replaces inserts)))
35
36
37
(defn edits1-replaces [a c b]
0 commit comments