[racket] Performance help

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Jan 1 14:12:28 EST 2015

Preface:

1. Your status quo version is about 16s on my laptop.

2. The output differs from your repo's output.txt on one item: It
corrects "accesing" to "accusing" rather than "acceding".

Next:

(append-map edits1 (edits1 s))

is very large -- 40,000+ items for "cat". But it looks like Norvig
prunes the edit distance 2 list to known words? Say where `ht` is the
training dict:

(define (edits2 ht s)
  (for*/list ([x (in-list (edits1 s))]
              [y (in-list (edits1 x))]
              #:when (hash-ref ht y #f))
    y))

That yields 2000+ items for "cat".

When I make that change, my run time decreases from ~16s to ~10s, and
produces the same output (which differs from output.txt in the same
way I mentioned above).

In relative terms this would probably get it close to the Python version?

Posted on the users mailing list.