good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Most specific pattern (edit distance)by Ovid (Cardinal) |
on Jun 30, 2005 at 21:14 UTC ( [id://471481]=note: print w/replies, xml ) | Need Help?? |
Now I'm just guessing, but it seems to me that what they want is the text that most closely corresponds to a given action. The concern is the text, not the regex. Since I haven't seen the data you work with, this might be way off base, but perhaps a better way would be to find all regexes that will match with the text and then choose the text with the smallest "edit distance" against a target text? Edit distance is generally concerned with the number of additions, deletions and substitutions necessary to transform one string into another. There are a number of CPAN modules which can calculate this for you. See Text::LevenshteinXS for a representative example. Cheers, New address of my CGI Course.
In Section
Seekers of Perl Wisdom
|
|