pluriTAL – BLOG Master pluriTAL [ParisX, ParisIII, INALCO]

Pour Françoise

Posté en Boîte à Outils, Master TAL Recherche, Projet 2008-2009, pluriTAL par pluritaluser à 15 mars 2009

#/usr/bin/perl

my $rep=”$ARGV[0]“;

$rep=~ s/[\/]$//;

my $DUMPFULL1=”";

my %tableaudestextes=(); #—————————————-

my $output1=”test1.xml”;

if (!open (FILEOUT,”>$output1″)) { die “Pb a l’ouverture du fichier $output1″};

&parcoursarborescencefichiers($rep);

sub parcoursarborescencefichiers {

 my $path = shift(@_);

opendir(DIR, $path) or die “can’t open $path: $!\n”;

my @files = readdir(DIR);

closedir(DIR);

foreach my $file (@files) {

next if $file =~ /^\.\.?$/;

 $file = $path.”/”.$file;

if (-d $file) {

&parcoursarborescencefichiers($file);

}

if (-f $file) {

if ($file=~/\.xml/){

open(FILEIN,$file);

printf “$file\n”;

   while ($ligne = <FILEIN>){

    if ($ligne=~/<description>([^<]+)<\/description>/){ 
 my $propre=$1;

 if (exists($tableaudestextes{$propre})) {

$tableaudestextes{$propre}++;

}

 else {

$DUMPFULL1.=”$propre\n”;

 $tableaudestextes{$propre}++;

}

}

}

}

 close(FILEIN);

}

 }

}

print FILEOUT “<?xml version=\”1.0\” encoding=\”iso-8859-1\” ?>\n”;
print FILEOUT “<PARCOURS>\n”;
print FILEOUT “<NOM> </NOM>\n”;
print FILEOUT “<FILTRAGE>”.$DUMPFULL1.”</FILTRAGE>\n”;
print FILEOUT “</PARCOURS>\n”;
close(FILEOUT);
exit;

Une réponse

Souscrire aux commentaires via RSS.

  1. pluritaluser soumis, le 18 mars 2009 at 6:17

    Merci Nassim, mais j’ai résolu le problème d’une autre façon Cf en bas.
    Françoise Del Socorro


Laisser un commentaire

Vous devez être connecté pour rédiger un commentaire.