#C:\Perl\bin\perl5.8.8.exe -w use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); #--------------------------------------Récupération des données du formulaire my $sequence=$ARGV[0]; $sequence =~ tr/+/ /; $sequence =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $sequence =~ s/</</g; $sequence =~ s/>/>/g; #-------------------------------------------------Traitement if (!open(FILEIN, "<chansons.xml")){die "Pb a l'ouverture du fichier Alignement.xml";}; print "Content-type: text/html\n\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">', "\n"; print "<html><head><title>Résultat de la recherche</title>\n"; print "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"; print "<style type=\"text/css\"><!--th {font-weight:bolt}--></style></head>\n"; print "<body bgcolor=\"#CCCCCC\"><a name=\"debut\"><ul>"; my $fr; my $kb; my $traduction; my @mots = (split / /, $sequence); foreach my $i (0..$#mots) { if (!open(FILEDICO, "<lexik.xml")){die "Pb a l'ouverture du fichier lexik.xml";}; while(my $ligne=<FILEDICO>) { if ($ligne=~/<mot(.+)<fr>(.+)<\/fr><kb>(.+)<\/k(.+)/i) { $fr=$2; $kb=$3; if ($fr eq $mots[$i]) { print "<li>Traduction : <span style=\"color:red\">$mots[$i]</span> = <span style=\"color:green\">$kb<\/span></h4></li>"; $traduction=$kb; last; } } } if (eof(FILEDICO)) { print "<li>Traduction : <span style=\"color:red\">$mots[$i]</span> = (non trouvée ?)</li>"; } close(FILEDICO); } print "</ul>"; my $langue="français"; my $j=0; print "<table border=\"0\" rules=\"rows\" style=\"margin-left:10px;margin-right:10px\">"; my $auteur=""; my $titre=""; my $k; while(my $ligne=<FILEIN>) { if ($ligne=~/<chanson num="(.+)" auteur="(.+)" titre="(.+)">/) { $auteur=$2; $titre=$3; $k=0; } if ($ligne=~/<element langue="fr">(.+)<\/element><element langue="kb">(.+)<\/element>/) { $fr=$1; $kb=$2; $k++; if ($fr=~/$sequence/) { $j++; $fr=~s/$sequence/<span style=\"color:red\">$sequence<\/span>/; $kb=~s/$traduction/<span style=\"color:green\">$traduction<\/span>/; if ($j==1) { print "<tr><th> N° </th><th> Contexte langue source </th><th> Contexte langue cible </th><th> Auteur <th> chanson </th></tr>\n"; } print "<tr><th> $j - </th><td> $fr </td><td> $kb </td><td> $auteur </td><td> $titre </td><td> $k </td></tr>\n"; } if ($kb=~/$sequence/) { $j++; $kb=~s/$sequence/<span style=\"color:red\">$sequence<\/span>/; $fr=~s/$traduction/<span style=\"color:green\">$traduction<\/span>/; if ($j==1) { print "<tr><th> N° </th><th> Contexte langue source </th><th> Contexte langue cible </th><th> Auteur <th> chanson </th></tr>\n"; } print "<tr><th> $j - </th><td> $fr </td><td> $kb </td><td> $auteur </td><td> $titre </td><td> $k </td></tr>\n"; } } } print "<tr> </tr></table>"; if ($j>18) { print "<a href=\"#debut\">Haut de page</a>"; } print "<br/><br/><i><div align=\"center\" style=\"font-size:75%\">Jugurtha Aït Hamlat - pluriTAL ©2009, INALCO, Paris 10, Paris 3</div></i></body></html>\n"; close(FILEIN);