- or download this
my @sentences = map { [ split ] } <>;
- or download this
my @uniq;
$uniq[ $_ ] = { map{ $_ => 1} @{ $sentences[ $_ ] } } for 0 .. $#sente
+nces;
- or download this
my( @aFragments, @bFragments );
for my $ai ( 0 .. $#sentences ) {
...
## process sentence[ $ai ] against sentences[ $bi ]
}
}
- or download this
sub fragmentSentence {
my( $sa, $ub ) = @_;
...
$a;
} [[]], @{ $sa };
}
- or download this
## if there are no common words between the sentences, exit ea
+rly
next unless first{ exists $ua->{ $_ } } keys %{ $ub };
...
## Output the sentence numbers and the best LCWS we found.
printf "( %4d / %4d )=>[ %s ]\n", $ai, $bi, join( ' ', @best )
+;
- or download this
#! perl -slw
use strict;
...
printf "( %4d / %4d )=>[ %s ]\n", $ai, $bi, join( ' ', @best )
+;
}
}