use strict; use locale; if ($#ARGV != 0){ die "Usage : ", $0, " LEXIQUE_REFERENCE\n"; } open(LEX, "<", $ARGV[0]) or die "impossible d'ouvrir ", $ARGV[0]; my %finale; while (my $ligne = ){ chomp($ligne); my ($forme, $lemme, $cat) = split(/\t/, $ligne); my $l = length($forme); for (my $i = 0; $i < $l; $i++){ $finale{substr($forme, $i)}{$cat} ++; } } close(LEX); while (my $ligne = ){ chomp($ligne); my $l = length($ligne); for (my $i = 0; $i < $l; $i++){ my $f = substr($ligne, $i); if (defined($finale{$f})){ my @c = sort {$finale{$f}{$b} <=> $finale{$f}{$a};} keys %{$finale{$f}}; print $ligne, "\t", $c[0], "\n"; last; } } }