CloseEnough: Typo correction in Elixir

Sushruth Siv
Tiny Tech Tales
Published in
1 min readMar 28, 2016

--

Not for production apps, or is it ?

There is a fun new package in town — CloseEnough. https://github.com/sivsushruth/close_enough

You need to add a process flag for :error_handler to let CloseEnough capture all undefined function errors. I have used levenshtein distance between available functions in the provided module and the “typo” function name to try and guess a suitable function.

Sample use case:

Integer.to_strign(123) gets converted to as Integer.to_string(123)

When this guess is successful the logger also warns you, saying

[warn] Could not find :strign using function :string instead

I was pointed out as soon as I posted the package, that Elixir core is also adding this functionality and will be released in the next version.

One suggestions I got was, use Jaro instead of levenshtein. I request you to review the package and provide constructive criticism.

--

--