From: "ara.t.howard" Date: 2008-04-03T16:12:36+09:00 Subject: Re: String 'close-to' comparison. On Apr 2, 2008, at 10:32 PM, Kyle Hunter wrote: > Hello, I have an array. It contains approximately twenty elements > which > are strings. I also have one string - this string was obtained using > an > OCR system. One of the strings in the array should 'match' the string > gotten using the OCR system - unfortunately OCRs aren't perfect! > > I want to take this string, and compare it to every string in the > array, > and attempt to return the closest match. > > I.E., > array = ['Hello there, how are you?', 'What did you do over your > break?', 'I like my coffee brown.", "I just bought a new car."] > string = "What did you d0 over your brcak?" > > > And then have my comparison function return array[1]. As you can see, > string has some 'OCR errors' - it's usually 80-95% accurate, if not > dead-on. > > -- > Thanks, Kyle 'Phenax' Hunter > http://keletech.org/blog/ > -- > Posted via http://www.ruby-forum.com/. http://amatch.rubyforge.org/ a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama