------ art_124535_13673756.1160993748920
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi list.
I read an article posted at Wikipedia about Levenshtein distance (aka edit
distance).
The location of the document is
http://en.wikipedia.org/wiki/Levenshtein_distance
In the document, a sample Ruby code goes like the following:
class String
def levenshtein(comparator)
a, b elf.unpack('U*'), comparator.unpack('U*')
n, m .length, b.length
a, b, n, m , a, m, n if n > m
current *0..n]
1.upto(m) do |i|
previous, current urrent, [i]+[0]*n
1.upto(n) do |j|
add, delete revious[j]+1, current[j-1]+1
change revious[j-1]
change + if a[j-1] ! [i-1]
current[j] add, delete, change].min
end
end
current[n]
end
end
In the code, there's a parameter called comparator which seems to be used to
decode given parameter. But, I can't understand what exactly the comparator
is doing.
Does anybody know the detail?
Sincerely,
Minkoo Seo
------ art_124535_13673756.1160993748920--