Help for this page

Select Code to Download


  1. or download this
    my @sentences = map { [ split ] } <>;
    
  2. or download this
    my @uniq;
    $uniq[ $_ ] = { map{ $_ => 1} @{ $sentences[ $_ ] } } for 0 .. $#sente
    +nces;
    
  3. or download this
    my( @aFragments, @bFragments );
    for my $ai ( 0 .. $#sentences ) {
    ...
            ## process sentence[ $ai ] against sentences[ $bi ]
        }
    }
    
  4. or download this
    sub fragmentSentence {
        my( $sa, $ub ) = @_;
    ...
           $a;
        } [[]], @{ $sa };
    }
    
  5. 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 )
    +;
    
  6. or download this
    #! perl -slw
    use strict;
    ...
            printf "( %4d / %4d )=>[ %s ]\n", $ai, $bi, join( ' ', @best )
    +;
        }
    }