1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| #!/usr/bin/perl -w
use strict;
my ($fichier, $ligne, $ligne1, $m, $cle, $val, $i);
my $mots_imb=0;
my (@zlo, @mots, @mots_imb);
my %stocke;
open (F, "<", "lefff-ext-3.2-pos.txt");
while (defined ($ligne= <F>)){
chomp ($ligne);
@zlo=split (/\t/, $ligne);
if ( defined $stocke{$zlo[0]}){
$stocke{$zlo[0]}.=",".$zlo[1];
} else {
$stocke{$zlo[0]}=$zlo[1];
}
}
print "Entrez le chemin vers le fichier a traiter: \n";
$fichier=<STDIN>;
chomp($fichier);
open (FI,"<", $fichier);
while (defined ($ligne1=<FI>)){
chomp($ligne1);
@mots = split(/(\pP|\pS|\s)/,lc $ligne1 );
while ( my ($cle, $val) = each(%stocke)) {
foreach $m(@mots){
if( $m eq $cle){
print "$m $val \n";
} else {
print "$m UNK \n";}
}
}}
}} |
Partager