#!/afs/athena/contrib/perl/p

$,=' ';
$|=1;
undef($/);
$doc = (<>);
$doc=~tr/A-Z/a-z/;
@words = split(' ', $doc);
for $plen (reverse(1..3)){
    for $n (0..$#words-$plen){
	$m = $n+$plen;
	$foo = join(' ',@words[$n..$m]);
	$phrase{$foo}++;
#	print("Added instance of $foo  ($n-$m)\n");
    }
}
print "Got $#words\n";
for (keys %phrase){
    if($phrase{$_} == 1){
	undef($phrase{$_});
    }
}

for (sort byvalue keys %phrase){
    print("$_-->  $phrase{$_}\n");
}

sub byvalue { $phrase{$b} <=> $phrase{$a};}
