Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Longest Common Substring

by Enlil (Parson)
on Apr 09, 2003 at 19:15 UTC ( [id://249362]=note: print w/replies, xml ) Need Help??


in reply to Re: Longest Common Substring
in thread Longest Common Substring

BrowserUK's solution doesn't quite work I tried the following and did not get back what was expected ( " the quick brown fox "):
my $needle = 'i pushed the lazy dog into a creek, the quick brown fox +told me to'; my $haystack = 'the quick brown fox jumps over the lazy dog';
and got back 'the lazy dog' (it works if you reverse the $needle and the $haystack.

But to his credit it seems to work better than String-LCSS-0.10, and he did mention that it might be incomplete (run it both ways, get the longest string and print that, I believe should give you the most right answer, but my tests might also be incomplete).

Where which running the following code:

require String::LCSS; my $needle = 'i pushed the lazy dog into a creek, the quick brown fox +told me to'; my $haystack = 'the quick brown fox jumps over the lazy dog'; my $longest = String::LCSS::lcss ( $needle, $haystack ); print $longest, "\n";
prints only 'lazy dog' (again it works reversing the $needle and the $haystack).

I would use Algorithm-Diff using this part of the documentation as a starting point.

Note: The Author of String-LCSS-0.10 has been notified.

-enlil

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://249362]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-26 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found