[Haskell-cafe] Re: Haskell version of Norvig's Python Spelling Corrector

Pete Kazmier pete-expires-20070615 at kazmier.com
Sun Apr 22 00:25:26 EDT 2007


Pete Kazmier <pete-expires-20070615 at kazmier.com> writes:

> I'd love to see other Haskell implementations as well if anyone has a
> few moments to spare.  Admittedly, it took me several hours to get my
> version working, but I'm a Haskell newbie.  Unfortunately, I think it
> runs as slow as it took me to write it!  There is definitely something
> wrong with it, a memory leak, because I can't correct more than a few
> words without a great deal of memory being consumed.

As monochrom pointed out on #haskell, I am using 'interact'
incorrectly.  For some reason I thought 'interact' applied its
argument to each line of the input.  I've replaced it as follows:

  interact $ unlines . map (show . (id &&& correct)) . lines

The program is still terribly slow due to my use of lists.  Is there a
better way to write 'edits1'?

Thanks,
Pete

 



More information about the Haskell-Cafe mailing list