From: Rainer Thiel Date: 2012-09-03T19:04:07+09:00 Subject: Re: Looking for patterns in a collection Robert Klemme wrote in post #1074405: > On Mon, Sep 3, 2012 at 12:52 AM, Rainer Thiel > wrote: >> So the comparison must proceed with some element of configurable >> tolerance. > > This seems to be the crucial point: you need to explicate what > "configurable tolerance" means. Only you can define that requirement. > Then someone might be able to answer the question: > Thanks Robert. I am trying to say that i don't expect any perfect matches, so the comparison should accommodate some (but not too much) variation, i.e. identify 'approximate' matches. I expect i will have to use a trial and error approach (hence configurable) to find an appropriate "tolerance level". Say for example i have the following four entries: {d1 => ['zero','one','two','three','four','five','six']} {d2 => ['zero','one','___','three','four','five','six']} {d3 => ['____','one','two','three','four','____','___']} {d4 => ['zero','one','two','three','four','five','six']} Say i define "tolerance level" as the maximum number of differences allowed before the comparison returns a mismatch, then: tolerance level 0 will match d1 and d4, tolerance level 1 will match d1, d2 and d4, tolerance level 2 will match d1, d2 and d4, tolerance level 3 will match all of them. Regards, Rainer -- Posted via http://www.ruby-forum.com/.