| 1 | package Org::FRDCSA::AIE::Method::SimpleLCS; | ||
| 2 | |||
| 3 | use Algorithm::Diff qw(LCS); | ||
| 4 | |||
| 5 | require Exporter; | ||
| 6 | @ISA = qw(Exporter); | ||
| 7 | @EXPORT = qw (AIE); | ||
| 8 | |||
| 9 | sub AIE { | ||
| 10 | my %args = @_; | ||
| 11 | my $entries = $args{Entries}; | ||
| 12 | my $size = scalar @$entries; | ||
| 13 | my @intermediate = split //, $entries->[0]; | ||
| 14 | foreach my $i (0 .. ($size - 2)) { | ||
| 15 | @intermediate = LCS(\@intermediate,[split //, $entries->[$i + 1]]); | ||
| 16 | } | ||
| 17 | my $regex = join("(.*)",@intermediate); | ||
| 18 | print $regex."\n"; | ||
| 19 | foreach my $entry (@$entries) { | ||
| 20 | my @results; | ||
| 21 | my @matches = $entry =~ /$regex/; | ||
| 22 | foreach my $match (@matches) { | ||
| 23 | if ($match ne "") { | ||
| 24 | push @results, $match; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | push @all,\@results; | ||
| 28 | } | ||
| 29 | return \@all; | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; |