<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Finding the Levenshtein Distance in Scala</title>
	<atom:link href="http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/</link>
	<description>The weblog of Tony Morris</description>
	<pubDate>Tue, 06 Jan 2009 13:36:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Anonymous Coward</title>
		<link>http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2280</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Thu, 08 May 2008 00:36:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2280</guid>
		<description>Gross... Preview is fin and posts are fuxxored :  third try.   That blog/post response is bugged... Preview is fine and it screws the posts once you click on 'submit comment'.  What you see is NOT what you get :)


Would this work :

&lt;code&gt;
if(a &#38;#38;lt b) a else if(b &#38;#38;lt= c) b else m(f)(i)(mx(i, _))(j - 1) + 1
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Gross&#8230; Preview is fin and posts are fuxxored :  third try.   That blog/post response is bugged&#8230; Preview is fine and it screws the posts once you click on &#8217;submit comment&#8217;.  What you see is NOT what you get <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Would this work :</p>
<p><code><br />
if(a &#38;#38;lt b) a else if(b &#38;#38;lt= c) b else m(f)(i)(mx(i, _))(j - 1) + 1<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous Coward</title>
		<link>http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2279</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Thu, 08 May 2008 00:34:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2279</guid>
		<description>erf...   Post got fuxxored.

I meant could the two lines be rewritten to this :

if(a &lt;b&gt;</description>
		<content:encoded><![CDATA[<p>erf&#8230;   Post got fuxxored.</p>
<p>I meant could the two lines be rewritten to this :</p>
<p>if(a <b></b></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous Coward</title>
		<link>http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2278</link>
		<dc:creator>Anonymous Coward</dc:creator>
		<pubDate>Thu, 08 May 2008 00:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.tmorris.net/finding-the-levenshtein-distance-in-scala/#comment-2278</guid>
		<description>Hi,

I wrote a spellchecker years ago :  I used lots of differents algos (including double-metaphone and algo finding 'probable typos') to find 'candidates', then I was using a Levenshtein edit distance to sort the candidates from 'most relevant' to 'less relevant'. Anyway...

I've got questions :  first, when working with large strings, using O(mn) memory, Chas Emerick noticed that he could not compare huge strings without getting out-of-memory errors, which lead him to write a version more efficient memory-wise (maybe he's doing DNA string matching ?  No idea...).  Anyway here is his algo:

http://www.merriampark.com/ldjava.htm

Does your Scala version here use O(mn) memory ?  If so, can it easily be changed to use less memory ?

You write: &lt;i&gt;the code builds the call stack as it traverses the matrix (the loopy one does not)&lt;/i&gt;.  So your version is actually a recursive version right?  If so then I guess it's unsuitable for big strings (even if the O(mn) memory problem, should it be in your version, could be fixed)!?

Then you write :

&lt;i&gt;The code has a better complexity than the typical loopy version by using lazy evaluation (notice that ‘c’ is not always evaluated)&lt;/i&gt;

I'm not familiar with Scala and I'm curious about it.  Could the following :

&lt;code&gt;
lazy val c = m(f)(i)(mx(i, _))(j - 1) + 1
if(a &lt;b&gt;

be rewritten with :

&lt;code&gt;
if(a &lt;b&gt;

and... Would that change anything (Scala-wise) ?

In my view, you used what is called the 'Top-down' approach to implement the DP algo: memoization and recursion combined.  While the more memory-efficient and more stack-efficient approach by Chas Emerick is the 'Bottom-up' approach ('Top-down' and 'Bottom-up' are defined on Wikipedia, under the Dynamic programming entry).

I must admit I'm surprised by the definition on Wikipedia :  to me the 'top-down' approach weren't DP, but simply memoization + recursion.

Anectodically, I find the bottom-up DP version of this algo easier to read then the recursive+memoization version (I mean, even if you were to write a recursive+memoization version of this DP algo in Java ;)

Lastly, after 0-1 Knapsak and edit distance, do you plan to have fun with all the DP algos ?  (Floyd-Warshall being next !? ;)</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I wrote a spellchecker years ago :  I used lots of differents algos (including double-metaphone and algo finding &#8216;probable typos&#8217;) to find &#8216;candidates&#8217;, then I was using a Levenshtein edit distance to sort the candidates from &#8216;most relevant&#8217; to &#8216;less relevant&#8217;. Anyway&#8230;</p>
<p>I&#8217;ve got questions :  first, when working with large strings, using O(mn) memory, Chas Emerick noticed that he could not compare huge strings without getting out-of-memory errors, which lead him to write a version more efficient memory-wise (maybe he&#8217;s doing DNA string matching ?  No idea&#8230;).  Anyway here is his algo:</p>
<p><a href="http://www.merriampark.com/ldjava.htm" onclick="javascript:pageTracker._trackPageview('/outbound/comment/www.merriampark.com');" rel="nofollow">http://www.merriampark.com/ldjava.htm</a></p>
<p>Does your Scala version here use O(mn) memory ?  If so, can it easily be changed to use less memory ?</p>
<p>You write: <i>the code builds the call stack as it traverses the matrix (the loopy one does not)</i>.  So your version is actually a recursive version right?  If so then I guess it&#8217;s unsuitable for big strings (even if the O(mn) memory problem, should it be in your version, could be fixed)!?</p>
<p>Then you write :</p>
<p><i>The code has a better complexity than the typical loopy version by using lazy evaluation (notice that ‘c’ is not always evaluated)</i></p>
<p>I&#8217;m not familiar with Scala and I&#8217;m curious about it.  Could the following :</p>
<p><code><br />
lazy val c = m(f)(i)(mx(i, _))(j - 1) + 1<br />
if(a <b></p>
<p>be rewritten with :</p>
<p><code><br />
if(a <b></p>
<p>and&#8230; Would that change anything (Scala-wise) ?</p>
<p>In my view, you used what is called the &#8216;Top-down&#8217; approach to implement the DP algo: memoization and recursion combined.  While the more memory-efficient and more stack-efficient approach by Chas Emerick is the &#8216;Bottom-up&#8217; approach (&#8217;Top-down&#8217; and &#8216;Bottom-up&#8217; are defined on Wikipedia, under the Dynamic programming entry).</p>
<p>I must admit I&#8217;m surprised by the definition on Wikipedia :  to me the &#8216;top-down&#8217; approach weren&#8217;t DP, but simply memoization + recursion.</p>
<p>Anectodically, I find the bottom-up DP version of this algo easier to read then the recursive+memoization version (I mean, even if you were to write a recursive+memoization version of this DP algo in Java <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Lastly, after 0-1 Knapsak and edit distance, do you plan to have fun with all the DP algos ?  (Floyd-Warshall being next !? <img src='http://blog.tmorris.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </b></code></b></code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
