Text::CommonParts - return the common starting parts of phrases
use Text::CommonParts qw(common_parts); # returns "sheep" common_parts("sheep shearing", "sheep dipping", "sheep rustling"); # returns "sheep", "sheep shearing" common_parts("sheep shearing", "sheep dipping", "sheep rustling", "sheep shearing shears"); # returns "sheep" shortest_common_parts("sheep shearing", "sheep dipping", "sheep rustling"); # returns "sheep" shortest_common_parts("sheep shearing", "sheep dipping", "sheep rustling", "sheep shearing shears");
Takes a list of phrases and returns the longest common parts.
If a phrase shares no common parts with any other phrases then it will be returned whole.
Given a set of phrases which have a common prt and a subset of phrases that have a longer common part then both parts will be returned. e.g given
"something good", "something bad", "something in the woodshed", "something in my eye"
will return
"something", "something in"
Same as common_parts but will not return subsets. e.g given
will just return
"something"
Simon Wistow <simon@thegestalt.org
Copyright 2006, Simon Wistow
Distributed under the same terms as Perl itself
To install Text::CommonParts, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::CommonParts
CPAN shell
perl -MCPAN -e shell install Text::CommonParts
For more information on module installation, please visit the detailed CPAN module installation guide.