<br><br><div class="gmail_quote">On Wed, Sep 1, 2010 at 2:31 AM, Joel Goldstick <span dir="ltr"><<a href="mailto:joel.goldstick@columbuswebmakers.com" target="_blank">joel.goldstick@columbuswebmakers.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div><a href="mailto:python@bdurham.com" target="_blank">python@bdurham.com</a> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm parsing a simple, domain specific scripting language that has<br>
commands like the following: *page, *title, *text, *footer, etc.<br>
There are about 100 of these '*' commands. When we see a command<br>
that we don't recognize, I would like to find the closest match<br>
possible (from a list of all legal commands) and include this<br>
suggestion in our diagnostic output.<br>
<br>
I'm not sure what you would call the type of algorithm I'm<br>
looking for: closest matching string or auto-correct?<br>
<br>
Any suggestions on algorithms or python libraries that would help<br>
me do what I'm looking for?<br>
<br>
Here's my short-list of ideas based on my research so far:<br>
- Soundex<br>
- Lawrence Philips' Metaphone Algorithm (from aspell?)<br>
- Edit Distance Algorithm<br>
- Levenstein Word Distance<br>
<br>
Any suggestions, comments on the above techniques, or ideas on a<br>
simpler algorithm for finding close string matches based on a<br>
list, dict, or set of possible strings?<br>
<br>
Thank you,<br>
Malcolm<br>
<br>
<br>
</blockquote></div></div>
Have you looked at difflib?<br></blockquote><div><br></div><div>On a side note, you can read this awesome article by Peter Norvig. <a href="http://norvig.com/spell-correct.html" target="_blank">http://norvig.com/spell-correct.html</a></div>


<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font color="#888888">
-- <br></font><div><div></div><div>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>~l0nwlf<br>