in reply to Re^11: partial match between 2 files
in thread partial match between 2 files
The code produces an error "Use of uninitialized value in print" when a word awiSayanA is compared with 2 words
awiSayaM
awiSayanZ
present in dictionary.Output is not produced.
|
|---|
| Replies are listed 'Best First'. | |||
|---|---|---|---|
|
Re^13: partial match between 2 files
by Athanasius (Archbishop) on Dec 28, 2012 at 09:53 UTC | |||
OK, so it appears that by “maximum partial match” you mean longest common substring. A search on that phrase found the thread finding longest common substring, from which I derived the following: Read more... (2 kB)
Update 1 (1st January, 2013): Algorithm::Diff is actually the wrong module for this, I should have used String::LCSS. The former finds non-contiguous sub-sequences; the latter finds substrings. Revised code:
Update 2 (1st January, 2013): It appears that String::LCSS is more badly broken than I realised. Even simple matches can fail to find the longest common substring:
(And see http://cpanratings.perl.org/dist/String-LCSS.) Better to replace sub lcss in the above script with the following by BrowserUk in Re: finding longest common substring:
Update 3 (2nd January, 2013): Discovered the thread Does String::LCSS work?. String::LCSS is indeed broken, but String::LCSS_XS seems to work correctly. Hope that helps,
| [reply] [d/l] [select] | ||
by lakssreedhar (Acolyte) on Jan 08, 2013 at 09:14 UTC | |||
A problem exists like this gets only longest common sub string.suppose my dictionary has words crick, cricketer and testing input is cricking,the match should be to crick but the program gives cricketer as closest matching string | [reply] | ||
by Athanasius (Archbishop) on Jan 10, 2013 at 16:30 UTC | |||
Hello lakssreedhar, As I understand it, you’re writing a script which accepts as input a word (which I will call the target) and the name of a dictionary file. The purpose of the script is to identify the best match for the target (if any) among the entries in the dictionary. Well, there would seem to be four possible ways in which a dictionary entry can match the target word: I suppose it’s obvious that if (1) is satisfied, this is the best match. And from earlier posts in this thread, it appears that if none of (1), (2), or (3) is true, then (4) looks for the the longest common substring (i.e., the “best” match is the one with the longest substring in common). But now things get murky. What if both (2) and (3) are satisfied? For example, the target is reread and the dictionary contains both read and rereading? And this is only one example of the sort of edge cases that need to be considered. suppose my dictionary has words crick, cricketer and testing input is cricking,the match should be to crick OK, but why? What are the rules for a “best match”? These rules need to be specified very precisely (and of course only you can do this, since only you know what your script is intended to do). Here is how I would approach the problem: Hope that gives you some help,
| [reply] | ||
by lakssreedhar (Acolyte) on Jan 12, 2013 at 04:46 UTC | |||