(suggestion threshold unknown knowns)
Provides a best suggestion for an unknown, taken from knowns,
minimizing the Levenshtein distance, returning nil if threshold
cannot be satisfied.
Source
(defn suggestion
"Provides a best suggestion for an unknown, taken from knowns,
minimizing the Levenshtein distance, returning nil if threshold
cannot be satisfied."
[threshold unknown knowns]
(let [distance (partial levenshtein-distance unknown)
closest (apply min-key distance knowns)
closest-dist (distance closest)]
(when (<= closest-dist threshold)
closest)))