Skip to content

Commit e101e4a

Browse files
committed
Add edits2. Now correct is very slow.
1 parent 74c1025 commit e101e4a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

back5/src/back5/spell.clj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
inserts (inserts s)]
4949
(merge-with max deletes transposes replaces inserts)))
5050

51+
(defn edits2 [word]
52+
(into {}
53+
(for [[word prob] (edits1 word)
54+
[word2 prob2] (edits1 word)]
55+
[word2 (* prob prob2)])))
56+
5157

5258
(defn edits1-replaces [a c b]
5359
(let [adjacents (get back5.error/adjacencies c)]
@@ -57,8 +63,6 @@
5763
(recur (rest adjacent-chars)
5864
(assoc replaces (str a (first adjacent-chars) b) 1))))))
5965

60-
(defn known-edits2 [word])
61-
6266
(defn known [words]
6367
(into {}
6468
(for [[word probability] words
@@ -70,6 +74,6 @@
7074
(sort-by #(- (val %))
7175
(merge-with max
7276
{word 0.1}
73-
(known-edits2 word)
77+
(known (edits2 word))
7478
(known {word 2})
7579
(known (edits1 word))))))

0 commit comments

Comments
 (0)