Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2629 connectés 

 


 Mot :   Pseudo :  
 
 Page :   1  2
Page Suivante
Auteur Sujet :

perl + comparaison + xml

n°2206156
rim_enis
j'aime ENIS
Posté le 09-10-2013 à 23:36:24  profilanswer
 

Reprise du message précédent :
gilou plz hel me !!

mood
Publicité
Posté le 09-10-2013 à 23:36:24  profilanswer
 

n°2206169
gilou
Modérateur
Modzilla
Posté le 10-10-2013 à 01:47:05  profilanswer
 

C'est juste un pb d'encodage:
si les fichier en entrée sont en utf8, et que je fais
open(my $fh, "<:utf8", $fname1); au lieu de open(my $fh, $fname1); et pareil pour $fname2, j'obtiens en sortie:


مَا-ثَمَّاشْ وَاحِدْ آخِرْ تَوَّةْ ؟  
 
ثَمَّةْ الحْدَاشْ مْتَاعْ-اللِيلْ  


 
A+,
 
 
 


---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --
n°2206316
rim_enis
j'aime ENIS
Posté le 10-10-2013 à 20:21:34  profilanswer
 

mais pkoi le résultat est fausse en fait il fait des autre concaténation et ajoute des lignes vides
 
أَيْتْفَضَّلْخُويَا.
 
مْعَوَقْتَاشْبِاللهْالتْرَانْيِمْشِي؟
 
. مَاضِي-سَاعَةْ وَ أَرْبْعَةْ

n°2206335
gilou
Modérateur
Modzilla
Posté le 10-10-2013 à 21:28:34  profilanswer
 

Je ne sais pas trop quel résultat vous voulez obtenir, mais si c'est ce que je pense, alors en remplaçant
foreach (<$fh> ) {
  foreach my $r (@biwords) {
    my $t = $r =~ s/ /-/r;
    if (/$r/) {
      s/$r/$t/g;  
     # print ;
  push @tab, $_;
    }
  }
}
par
foreach (<$fh> ) {
    foreach my $r (@biwords) {
        if (/$r/) {
            my $t = $r;
            $t =~ tr/ /-/;
            s/$r/$t/g;  
        }
    }
    push @tab, $_;
}
ça fera peut être l'affaire.
 
A+,


---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --
n°2206348
rim_enis
j'aime ENIS
Posté le 10-10-2013 à 22:38:59  profilanswer
 

gilou a écrit :

Bonjour :)
C'est splitté dans le code, simplement l'affichage ne fait rien (pas de saut de ligne après) pour les mots qui ne sont pas dans la base.
C'est très simple à modifier si on veut un saut de ligne systématique.
 

Code :
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use XML::Simple;
  5. use Encode;
  6. use autodie;
  7. use feature 'unicode_strings';
  8. # en entrée, une reference sur un hash %syn et le nom du fichier xml
  9. # en sortie %syn est rempli avec comme clés et les étiquettes comme valeurs.
  10. sub parseBase ($$) {
  11.   use XML::Simple;
  12.   my $href = shift;
  13.   my $data = XMLin(shift);
  14.   foreach (@{$data->{mot}}) {
  15.     s/^\s+|\s+$//g;
  16.     next if (/^$/);
  17.     my $synonyme = $_->{'synonyme'};
  18.     next if (ref($synonyme));
  19.     $synonyme =~ s/^\s+|\s+$//g;
  20.     next if ($synonyme ~~ /^$/);
  21.     my $etiquette = $_->{'etiquette'};
  22.     next if (ref($etiquette));
  23.     $etiquette =~ s/^\s+|\s+$//g;
  24.     next if ($etiquette ~~ /^$/);
  25.     $$href{$synonyme} = $etiquette;
  26.   }
  27. }
  28. my %syn;
  29. parseBase(\%syn, 'BaseEtiquettes.xml');
  30. open my $fh,  "<:utf8", 'CorpusNettoye.txt';
  31. open my $fh1, ">:utf8", 'toto.txt';
  32. my $linenum = 0;
  33. foreach (<$fh> ) {
  34.   # Si BOM initiale
  35.   unless ($linenum++ or not /^\x{feff}/) {
  36.     s/^\x{feff}// ;
  37.     print $fh1 "\x{feff}";
  38.   }
  39.   my @words = split /(\b|\x{061F}|\x{061B})/;
  40.   foreach (@words) {
  41.     s/^\s+|\s+$//g;
  42.     next if (/^$/);
  43.     next if (/^\r?\n$/);  # élimination des mots vides, retours de ligne, etc
  44.     print $fh1 $_;
  45.     # si le mot figure dans la liste des synonymes
  46.     if ($syn{$_}) {
  47.       print $fh1  " $syn{$_}";
  48.     }
  49.     print $fh1  " \n";  # va splitter à l'affichage pour tous les mots non vides qu'ils soient dans la base ou non
  50.   }
  51. }
  52. close $fh1;
  53. close $fh;


parseBase a aissi été modifié tant que j'y étais afin de tenir compte dee entrées avec du blanc autour: <synonyme>تْفَضَّلْ </synonyme>  et des entrées vides:  <etiquette></etiquette>  
Avec vos données, j'ai maintenant en sortie:

. Point  
أَيْ confirmation  
تْفَضَّلْ politesse  
خُويَا nomination  
مْعَ  
وَقْتَاشْ outil question demande horaire  
بِاللهْ demande  
التْرَانْ marq train  
يِمْشِي marq depart  
؟ Point Interrogation  
. Point  
مَاضِي  
سَاعَةْ  
وَ coordination  
أَرْبْعَةْ nombre  
مَا  
ثَمَّاشْ  
وَاحِدْ  
آخِرْ  
تَوَّةْ  
؟ Point Interrogation  
. Point  
لاَ  
هَاكَ  
هَذَاكَ  
هُوَ  
ثَمَّاشِي  
وَاحِدْ  
آخِرْ  
بَعْدُو  
؟ Point Interrogation  
ثَمَّةْ  
الحْدَاشْ  
مْتَاعْ  
اللِيلْ  
سَلَامُ  
عَلَيْكُمْ  
بِاللهْ demande  
تِكَايْ  
لْتُونِسْ  
بْقَدَّاهْ  
؟ Point Interrogation  
ثْنَاشْ  
وُ  
تْسْعَةْ  
مِيَّةْ  
. Point  
سَلَامُ  
عَلَيْكُمْ  
. Point  
زُوزْ  
زُوزْ  
لْتُونِسْ  
وَقْتَاشْ outil question demande horaire  
يُخْرِجْ  


A vous d'adapter à vos besoins si nécessaire.
 
A+,


 
 
si dans mon fichier j'ai des mots de ce genre : مَاضِي-سَاعَةْ  comment je peux modifier l'expression regulière afin de considérer مَاضِي-سَاعَةْ comme un seul mot et non pas 3 mots  

n°2206352
gilou
Modérateur
Modzilla
Posté le 10-10-2013 à 22:58:32  profilanswer
 

Je pense qu'il faut modifier la regexp du split avec un negative look behind et un negative look ahead
my @words = split /(?<!-)(\b|\x{061F}|\x{061B})(?!-)/;
 
A+,


---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --
n°2214424
rim_enis
j'aime ENIS
Posté le 25-12-2013 à 17:22:37  profilanswer
 

bonoir gilou ,
 
j'ai encore des problèmes avec perl , merci de m'aider SVP ,
 
voici mon programme perl :  
 

Code :
  1. use strict;
  2. use warnings;
  3. use autodie;
  4. use XML::TreeBuilder;
  5. my %h1;
  6. my $tree = XML::TreeBuilder->new();
  7. $tree->parse_file('/home/hp/Bureau/Master/fic2.xml');
  8. my @mots = $tree->find('mot');
  9. foreach (@mots) {
  10.         s/^\s+|\s+$//g;
  11.         next if (/^$/);
  12. my ($synonyme, $etiquette);
  13. foreach ($_->descendants()) {
  14.    my $tag = $_->tag();
  15.    if ($tag ~~ "synonyme" ) {
  16.      $synonyme = ($_->content_list())[0];
  17.         next if (ref($synonyme));
  18.         $synonyme =~ s/^\s+|\s+$//g;
  19.         next if ($synonyme ~~ /^$/);
  20.    }
  21.    if ($tag ~~ "etiquette" ) {
  22.      $etiquette = ($_->content_list())[0];
  23.     next if (ref($etiquette));
  24.         $etiquette =~ s/^\s+|\s+$//g;
  25.         next if ($etiquette ~~ /^$/);
  26.      $h1{$synonyme} = $etiquette;
  27.    }
  28. }
  29. }
  30. $tree->delete;
  31. my %h2;
  32. $tree = XML::TreeBuilder->new();
  33. $tree->parse_file('/home/hp/Bureau/Master/fic3.xml');
  34. my @classes = $tree->find('classe');
  35. foreach (@classes) {
  36. s/^\s+|\s+$//g;
  37.         next if (/^$/);
  38. #my $synonyme = $_->{'synonyme'};
  39.        # next if (ref($synonyme));
  40. my ($nom, $etiquette);
  41. foreach ($_->descendants()) {
  42.    my $tag = $_->tag();
  43.    if ($tag ~~ "nom" ) {
  44.      $nom = ($_->content_list())[0];
  45. next if (ref($nom));
  46.         $nom =~ s/^\s+|\s+$//g;
  47.         next if ($nom ~~ /^$/);
  48.    }
  49.    if ($tag ~~ /^etiquette\d+$/) {
  50.      $etiquette = ($_->content_list())[0];
  51. next if (ref($etiquette));
  52.         $etiquette =~ s/^\s+|\s+$//g;
  53.         next if ($etiquette ~~ /^$/);
  54.      $h2{$etiquette}= $nom;
  55.    }
  56. }
  57. }
  58. $tree->delete;
  59. open my $fh,  "<:utf8 ", '/home/hp/Bureau/Master/sortie2.txt';
  60. open my $fh1, ">:utf8", '/home/hp/Bureau/Master/sortie3.txt';
  61. my $linenum = 0;
  62. my (@bloc, @words);
  63. my $Appelation="";
  64. my $Obligation="";
  65. my $Ville="";
  66. my $Comparaison="";
  67. my $MotOutil="";
  68. my $AutreMots="";
  69. my $Autre="";
  70. my $Disponibilite="";
  71. my $Nombre="";
  72. my $Annees="";
  73. my $MoyenTransport="";
  74. my $Action="";
  75. my $Etat="";
  76. my $Certitude="";
  77. my $Jure="";
  78. my $Demande="";
  79. my $Politesse="";
  80. my $OutilQuestion="";
  81. my $Lieu="";
  82. my $Amorce="";
  83. my $Salutation="";
  84. my $TypeTrain="";
  85. my $ClasseTrain="";
  86. my $Mois="";
  87. my $Jour="";
  88. my $Horaires="";
  89. my $Nomination="";
  90. my $Hesitation="";
  91. my $Reponse="";
  92. my $Monnaie="";
  93. my $Pronom="";
  94. my $Quantite="";
  95. my $Promotion="";
  96. my $Billet="";
  97. my $Voyageur="";
  98. my $Carte="";
  99. my $Possibilite="";
  100.        
  101. foreach(<$fh> ) {
  102. unless ($linenum++ or not /^\x{feff}/) {
  103.    s/^\x{feff}// ;
  104. }
  105. if (/^\s*$/) {
  106.    if (0+@bloc) {
  107. #print $fh1 join(" ", @bloc), "\n";
  108.      @bloc = ();
  109.    }
  110. }
  111. else {
  112. chomp;
  113.    s/^\s+|\s+$//g;
  114.    @words = split /\s+/;
  115.    if (defined($h1{$words[0]}) and defined($h2{$h1{$words[0]}})) {
  116.  
  117. if ($h2{$h1{$words[0]}} ~~ "Appelation" ) {
  118.    
  119. $Appelation .= " $words[0]";
  120. }
  121. if ($h2{$h1{$words[0]}} ~~ "Obligation" ) {
  122.    
  123. $Obligation .= " $words[0]";
  124. if ($h2{$h1{$words[0]}} ~~ "Ville" ) {
  125.    
  126. $Ville .= " $words[0]";
  127. }
  128. if ($h2{$h1{$words[0]}} ~~ "Comparaison" ) {
  129.    
  130. $Comparaison .= " $words[0]";
  131. }
  132. if ($h2{$h1{$words[0]}} ~~ "Mot-Outil" ) {
  133.    
  134. $MotOutil .= " $words[0]";
  135. }
  136. if ($h2{$h1{$words[0]}} ~~ "Autre-Mots" ) {
  137.    
  138. $AutreMots .= " $words[0]";
  139. }
  140. if ($h2{$h1{$words[0]}} ~~ "Autre" ) {
  141.    
  142. $Autre .= " $words[0]";
  143. }
  144. if ($h2{$h1{$words[0]}} ~~ "Disponibilite" ) {
  145.    
  146. $Disponibilite .= " $words[0]";
  147. }
  148. if ($h2{$h1{$words[0]}} ~~ "Nombre" ) {
  149.    
  150. $Nombre .= " $words[0]";
  151. }
  152. if ($h2{$h1{$words[0]}} ~~ "Annees" ) {
  153.    
  154. $Annees .= " $words[0]";
  155. }
  156. if ($h2{$h1{$words[0]}} ~~ "Moyen-Transport" ) {
  157.    
  158. $MoyenTransport .= " $words[0]";
  159. }
  160. if ($h2{$h1{$words[0]}} ~~ "Possibilite" ) {
  161.    
  162. $Possibilite .= " $words[0]";
  163. if ($h2{$h1{$words[0]}} ~~ "Action" ) {
  164.    
  165. $Action .= " $words[0]";
  166. }
  167. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  168.    
  169. $Etat .= " $words[0]";
  170. }
  171. if ($h2{$h1{$words[0]}} ~~ "Certitude" ) {
  172.    
  173. $Certitude .= " $words[0]";
  174. }
  175. if ($h2{$h1{$words[0]}} ~~ "Jure" ) {
  176.    
  177. $Jure .= " $words[0]";
  178. }
  179. if ($h2{$h1{$words[0]}} ~~ "Demande" ) {
  180.    
  181. $Demande .= " $words[0]";
  182. }
  183. if ($h2{$h1{$words[0]}} ~~ "Politesse" ) {
  184.    
  185. $Politesse .= " $words[0]";
  186. }
  187. if ($h2{$h1{$words[0]}} ~~ "Outil-Question" ) {
  188.    
  189. $OutilQuestion .= " $words[0]";
  190. }
  191. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  192.    
  193. $Etat .= " $words[0]";
  194. }
  195. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  196.    
  197. $Etat .= " $words[0]";
  198. }
  199. if ($h2{$h1{$words[0]}} ~~ "Lieu" ) {
  200.    
  201. $Lieu .= " $words[0]";
  202. }
  203. if ($h2{$h1{$words[0]}} ~~ "Amorce" ) {
  204.    
  205. $Amorce .= " $words[0]";
  206. }
  207. if ($h2{$h1{$words[0]}} ~~ "Salutation" ) {
  208.    
  209. $Salutation .= " $words[0]";
  210. }
  211. if ($h2{$h1{$words[0]}} ~~ "Type-Train" ) {
  212.    
  213. $TypeTrain .= " $words[0]";
  214. }
  215. if ($h2{$h1{$words[0]}} ~~ "Classe-Train" ) {
  216.    
  217. $ClasseTrain .= " $words[0]";
  218. }
  219. if ($h2{$h1{$words[0]}} ~~ "Mois" ) {
  220.    
  221. $Mois .= " $words[0]";
  222. }
  223. if ($h2{$h1{$words[0]}} ~~ "Jour" ) {
  224.    
  225. $Jour .= " $words[0]";
  226. }
  227. if ($h2{$h1{$words[0]}} ~~ "Horaires" ) {
  228.    
  229. $Horaires .= " $words[0]";
  230. }
  231. if ($h2{$h1{$words[0]}} ~~ "Nomination" ) {
  232.    
  233. $Nomination .= " $words[0]";
  234. }
  235. if ($h2{$h1{$words[0]}} ~~ "Hesitation" ) {
  236.    
  237. $Hesitation .= " $words[0]";
  238. }
  239. if ($h2{$h1{$words[0]}} ~~ "Reponse" ) {
  240.    
  241. $Reponse .= " $words[0]";
  242. }
  243. if ($h2{$h1{$words[0]}} ~~ "Monnaie" ) {
  244.    
  245. $Monnaie .= " $words[0]";
  246. }
  247. if ($h2{$h1{$words[0]}} ~~ "Pronom" ) {
  248.    
  249. $Pronom .= " $words[0]";
  250. }
  251.    
  252. }
  253. if ($h2{$h1{$words[0]}} ~~ "Quantite" ) {
  254.    
  255. $Quantite .= " $words[0]";
  256. }
  257. if ($h2{$h1{$words[0]}} ~~ "Promotion" ) {
  258.    
  259. $Promotion .= " $words[0]";
  260. }
  261. if ($h2{$h1{$words[0]}} ~~ "Billet" ) {
  262.    
  263. $Billet .= " $words[0]";
  264. }
  265. if ($h2{$h1{$words[0]}} ~~ "Voyageur" ) {
  266.    
  267. $Voyageur .= " $words[0]";
  268. }
  269. if ($h2{$h1{$words[0]}} ~~ "Carte" ) {
  270.    
  271. $Carte .= " $words[0]";
  272. }
  273. }
  274. }
  275. push @bloc, "  Appelation ".$Appelation;
  276. push @bloc, "\n";
  277. push @bloc, "Obligation ".$Obligation;
  278. push @bloc, "\n";
  279. push @bloc, "Ville ".$Ville;
  280. push @bloc, "\n";
  281. push @bloc, "Comparaison ".$Comparaison;
  282. push @bloc, "\n";
  283. push @bloc, "Mot-Outil ".$MotOutil;
  284. push @bloc, "\n";
  285. push @bloc, "Autre-Mots ".$AutreMots;
  286. push @bloc, "\n";
  287. push @bloc, "Autre ".$Autre;
  288. push @bloc, "\n";
  289. push @bloc, "Disponibilite ".$Disponibilite;
  290. push @bloc, "\n";
  291. push @bloc, "Nombre ".$Nombre;
  292. push @bloc, "\n";
  293. push @bloc, "Annees ".$Annees;
  294. push @bloc, "\n";
  295. push @bloc, "Moyen-Transport ".$MoyenTransport;
  296. push @bloc, "\n";
  297. push @bloc, "Action ".$Action;
  298. push @bloc, "\n";
  299. push @bloc, "Etat ".$Etat;
  300. push @bloc, "\n";
  301. push @bloc, "Certitude ".$Certitude;
  302. push @bloc, "\n";
  303. push @bloc, "Jure ".$Jure;
  304. push @bloc, "\n";
  305. push @bloc, "Demande ".$Demande;
  306. push @bloc, "\n";
  307. push @bloc, "Politesse ".$Politesse;
  308. push @bloc, "\n";
  309. push @bloc, "Outil-Question ".$OutilQuestion;
  310. push @bloc, "\n";
  311. push @bloc, "Lieu ".$Lieu;
  312. push @bloc, "\n";
  313. push @bloc, "Amorce ".$Amorce;
  314. push @bloc, "\n";
  315. push @bloc, "Salutation ".$Salutation;
  316. push @bloc, "\n";
  317. push @bloc, "Type-Train ".$TypeTrain;
  318. push @bloc, "\n";
  319. push @bloc, "Classe-Train ".$ClasseTrain;
  320. push @bloc, "\n";
  321. push @bloc, "Mois ".$Mois;
  322. push @bloc, "\n";
  323. push @bloc, "Jour ".$Jour;
  324. push @bloc, "\n";
  325. push @bloc, "Horaires ".$Horaires;
  326. push @bloc, "\n";
  327. push @bloc, "Nomination ".$Nomination;
  328. push @bloc, "\n";
  329. push @bloc, "Hesitation ".$Hesitation;
  330. push @bloc, "\n";
  331. push @bloc, "Reponse ".$Reponse;
  332. push @bloc, "\n";
  333. push @bloc, "Monnaie ".$Monnaie;
  334. push @bloc, "\n";
  335. push @bloc, "Pronom".$Pronom;
  336. push @bloc, "\n";
  337. push @bloc, "Quantite ".$Quantite;
  338. push @bloc, "\n";
  339. push @bloc, "Promotion ".$Promotion;
  340. push @bloc, "\n";
  341. push @bloc, "Billet ".$Billet;
  342. push @bloc, "\n";
  343. push @bloc, "Voyageur ".$Voyageur;
  344. push @bloc, "\n";
  345. push @bloc, "Carte ".$Carte;
  346. push @bloc, "\n";
  347. if (0+@bloc) {
  348. print $fh1 join("  ", @bloc), "\n";
  349. }


 
avec  
fic2.xml :
 
<mot>
<synonyme>أُصْرُفْ</synonyme>
<etiquette>Marqueur-Payement</etiquette>
</mot>
<mot>
<synonyme>نْخَلِّيكْ</synonyme>
<etiquette>Mot</etiquette>
</mot>
<mot>
<synonyme>تَرْجَعْلي</synonyme>
<etiquette>Mot</etiquette>
</mot>
 
 
fic3.xml  
<classe>
<nom>Certitude</nom>
<etiquette1>Incertitude</etiquette1>
<etiquette2>Certitude</etiquette2>
</classe>
 
 
<classe>
<nom>Jure</nom>
<etiquette1>Jure</etiquette1>
</classe>
 
 
<classe>
<nom>Reponse</nom>
<etiquette1>Confirmation</etiquette1>
<etiquette2>Negation</etiquette2>
<etiquette3>Reponse</etiquette3>
</classe>
 
 
et sortie2.txt :
 
تْفَضَّلْ
خُويَا
مْعَ
وَقْتَاشْ
بِاللهْ
التْرَانْ
يِمْشِي
مَاضِي
سَاعَةْ
وَ
أَرْبْعَةْ
مَا
ثَمَّاشْ
وَاحِدْ
 
 
 
 
mon but est faire un programme dont la sortie est la suivante :  
 
 
nom de classe mot1 mot2 mot3 ....

 
 
avec nom de classe est le nom de classe du fichier fic3.txt et word1 word2 etc sont le mots ds sortie.txt tout en utilisant la base fic2.xml
 
 
mon problème et que je constate qu'il ya des mots ds sortie2 qui non pas classé , peut etre c'est un problème des espaces  
 
 
 
 
 
 
 
 
 

n°2214425
rim_enis
j'aime ENIS
Posté le 25-12-2013 à 17:33:50  profilanswer
 

bonoir gilou ,
 
j'ai encore des problèmes avec perl , merci de m'aider SVP ,
 
voici mon programme perl :  
 

Code :
  1. use strict;
  2. use warnings;
  3. use autodie;
  4. use XML::TreeBuilder;
  5. my %h1;
  6. my $tree = XML::TreeBuilder->new();
  7. $tree->parse_file('/home/hp/Bureau/Master/fic2.xml');
  8. my @mots = $tree->find('mot');
  9. foreach (@mots) {
  10.         s/^\s+|\s+$//g;
  11.         next if (/^$/);
  12. my ($synonyme, $etiquette);
  13. foreach ($_->descendants()) {
  14.    my $tag = $_->tag();
  15.    if ($tag ~~ "synonyme" ) {
  16.      $synonyme = ($_->content_list())[0];
  17.         next if (ref($synonyme));
  18.         $synonyme =~ s/^\s+|\s+$//g;
  19.         next if ($synonyme ~~ /^$/);
  20.    }
  21.    if ($tag ~~ "etiquette" ) {
  22.      $etiquette = ($_->content_list())[0];
  23.     next if (ref($etiquette));
  24.         $etiquette =~ s/^\s+|\s+$//g;
  25.         next if ($etiquette ~~ /^$/);
  26.      $h1{$synonyme} = $etiquette;
  27.    }
  28. }
  29. }
  30. $tree->delete;
  31. my %h2;
  32. $tree = XML::TreeBuilder->new();
  33. $tree->parse_file('/home/hp/Bureau/Master/fic3.xml');
  34. my @classes = $tree->find('classe');
  35. foreach (@classes) {
  36. s/^\s+|\s+$//g;
  37.         next if (/^$/);
  38. #my $synonyme = $_->{'synonyme'};
  39.        # next if (ref($synonyme));
  40. my ($nom, $etiquette);
  41. foreach ($_->descendants()) {
  42.    my $tag = $_->tag();
  43.    if ($tag ~~ "nom" ) {
  44.      $nom = ($_->content_list())[0];
  45. next if (ref($nom));
  46.         $nom =~ s/^\s+|\s+$//g;
  47.         next if ($nom ~~ /^$/);
  48.    }
  49.    if ($tag ~~ /^etiquette\d+$/) {
  50.      $etiquette = ($_->content_list())[0];
  51. next if (ref($etiquette));
  52.         $etiquette =~ s/^\s+|\s+$//g;
  53.         next if ($etiquette ~~ /^$/);
  54.      $h2{$etiquette}= $nom;
  55.    }
  56. }
  57. }
  58. $tree->delete;
  59. open my $fh,  "<:utf8 ", '/home/hp/Bureau/Master/sortie2.txt';
  60. open my $fh1, ">:utf8", '/home/hp/Bureau/Master/sortie3.txt';
  61. my $linenum = 0;
  62. my (@bloc, @words);
  63. my $Appelation="";
  64. my $Obligation="";
  65. my $Ville="";
  66. my $Comparaison="";
  67. my $MotOutil="";
  68. my $AutreMots="";
  69. my $Autre="";
  70. my $Disponibilite="";
  71. my $Nombre="";
  72. my $Annees="";
  73. my $MoyenTransport="";
  74. my $Action="";
  75. my $Etat="";
  76. my $Certitude="";
  77. my $Jure="";
  78. my $Demande="";
  79. my $Politesse="";
  80. my $OutilQuestion="";
  81. my $Lieu="";
  82. my $Amorce="";
  83. my $Salutation="";
  84. my $TypeTrain="";
  85. my $ClasseTrain="";
  86. my $Mois="";
  87. my $Jour="";
  88. my $Horaires="";
  89. my $Nomination="";
  90. my $Hesitation="";
  91. my $Reponse="";
  92. my $Monnaie="";
  93. my $Pronom="";
  94. my $Quantite="";
  95. my $Promotion="";
  96. my $Billet="";
  97. my $Voyageur="";
  98. my $Carte="";
  99. my $Possibilite="";
  100.        
  101. foreach(<$fh> ) {
  102. unless ($linenum++ or not /^\x{feff}/) {
  103.    s/^\x{feff}// ;
  104. }
  105. if (/^\s*$/) {
  106.    if (0+@bloc) {
  107. #print $fh1 join(" ", @bloc), "\n";
  108.      @bloc = ();
  109.    }
  110. }
  111. else {
  112. chomp;
  113.    s/^\s+|\s+$//g;
  114.    @words = split /\s+/;
  115.    if (defined($h1{$words[0]}) and defined($h2{$h1{$words[0]}})) {
  116.  
  117. if ($h2{$h1{$words[0]}} ~~ "Appelation" ) {
  118.    
  119. $Appelation .= " $words[0]";
  120. }
  121. if ($h2{$h1{$words[0]}} ~~ "Obligation" ) {
  122.    
  123. $Obligation .= " $words[0]";
  124. if ($h2{$h1{$words[0]}} ~~ "Ville" ) {
  125.    
  126. $Ville .= " $words[0]";
  127. }
  128. if ($h2{$h1{$words[0]}} ~~ "Comparaison" ) {
  129.    
  130. $Comparaison .= " $words[0]";
  131. }
  132. if ($h2{$h1{$words[0]}} ~~ "Mot-Outil" ) {
  133.    
  134. $MotOutil .= " $words[0]";
  135. }
  136. if ($h2{$h1{$words[0]}} ~~ "Autre-Mots" ) {
  137.    
  138. $AutreMots .= " $words[0]";
  139. }
  140. if ($h2{$h1{$words[0]}} ~~ "Autre" ) {
  141.    
  142. $Autre .= " $words[0]";
  143. }
  144. if ($h2{$h1{$words[0]}} ~~ "Disponibilite" ) {
  145.    
  146. $Disponibilite .= " $words[0]";
  147. }
  148. if ($h2{$h1{$words[0]}} ~~ "Nombre" ) {
  149.    
  150. $Nombre .= " $words[0]";
  151. }
  152. if ($h2{$h1{$words[0]}} ~~ "Annees" ) {
  153.    
  154. $Annees .= " $words[0]";
  155. }
  156. if ($h2{$h1{$words[0]}} ~~ "Moyen-Transport" ) {
  157.    
  158. $MoyenTransport .= " $words[0]";
  159. }
  160. if ($h2{$h1{$words[0]}} ~~ "Possibilite" ) {
  161.    
  162. $Possibilite .= " $words[0]";
  163. if ($h2{$h1{$words[0]}} ~~ "Action" ) {
  164.    
  165. $Action .= " $words[0]";
  166. }
  167. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  168.    
  169. $Etat .= " $words[0]";
  170. }
  171. if ($h2{$h1{$words[0]}} ~~ "Certitude" ) {
  172.    
  173. $Certitude .= " $words[0]";
  174. }
  175. if ($h2{$h1{$words[0]}} ~~ "Jure" ) {
  176.    
  177. $Jure .= " $words[0]";
  178. }
  179. if ($h2{$h1{$words[0]}} ~~ "Demande" ) {
  180.    
  181. $Demande .= " $words[0]";
  182. }
  183. if ($h2{$h1{$words[0]}} ~~ "Politesse" ) {
  184.    
  185. $Politesse .= " $words[0]";
  186. }
  187. if ($h2{$h1{$words[0]}} ~~ "Outil-Question" ) {
  188.    
  189. $OutilQuestion .= " $words[0]";
  190. }
  191. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  192.    
  193. $Etat .= " $words[0]";
  194. }
  195. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  196.    
  197. $Etat .= " $words[0]";
  198. }
  199. if ($h2{$h1{$words[0]}} ~~ "Lieu" ) {
  200.    
  201. $Lieu .= " $words[0]";
  202. }
  203. if ($h2{$h1{$words[0]}} ~~ "Amorce" ) {
  204.    
  205. $Amorce .= " $words[0]";
  206. }
  207. if ($h2{$h1{$words[0]}} ~~ "Salutation" ) {
  208.    
  209. $Salutation .= " $words[0]";
  210. }
  211. if ($h2{$h1{$words[0]}} ~~ "Type-Train" ) {
  212.    
  213. $TypeTrain .= " $words[0]";
  214. }
  215. if ($h2{$h1{$words[0]}} ~~ "Classe-Train" ) {
  216.    
  217. $ClasseTrain .= " $words[0]";
  218. }
  219. if ($h2{$h1{$words[0]}} ~~ "Mois" ) {
  220.    
  221. $Mois .= " $words[0]";
  222. }
  223. if ($h2{$h1{$words[0]}} ~~ "Jour" ) {
  224.    
  225. $Jour .= " $words[0]";
  226. }
  227. if ($h2{$h1{$words[0]}} ~~ "Horaires" ) {
  228.    
  229. $Horaires .= " $words[0]";
  230. }
  231. if ($h2{$h1{$words[0]}} ~~ "Nomination" ) {
  232.    
  233. $Nomination .= " $words[0]";
  234. }
  235. if ($h2{$h1{$words[0]}} ~~ "Hesitation" ) {
  236.    
  237. $Hesitation .= " $words[0]";
  238. }
  239. if ($h2{$h1{$words[0]}} ~~ "Reponse" ) {
  240.    
  241. $Reponse .= " $words[0]";
  242. }
  243. if ($h2{$h1{$words[0]}} ~~ "Monnaie" ) {
  244.    
  245. $Monnaie .= " $words[0]";
  246. }
  247. if ($h2{$h1{$words[0]}} ~~ "Pronom" ) {
  248.    
  249. $Pronom .= " $words[0]";
  250. }
  251.    
  252. }
  253. if ($h2{$h1{$words[0]}} ~~ "Quantite" ) {
  254.    
  255. $Quantite .= " $words[0]";
  256. }
  257. if ($h2{$h1{$words[0]}} ~~ "Promotion" ) {
  258.    
  259. $Promotion .= " $words[0]";
  260. }
  261. if ($h2{$h1{$words[0]}} ~~ "Billet" ) {
  262.    
  263. $Billet .= " $words[0]";
  264. }
  265. if ($h2{$h1{$words[0]}} ~~ "Voyageur" ) {
  266.    
  267. $Voyageur .= " $words[0]";
  268. }
  269. if ($h2{$h1{$words[0]}} ~~ "Carte" ) {
  270.    
  271. $Carte .= " $words[0]";
  272. }
  273. }
  274. }
  275. push @bloc, "  Appelation ".$Appelation;
  276. push @bloc, "\n";
  277. push @bloc, "Obligation ".$Obligation;
  278. push @bloc, "\n";
  279. push @bloc, "Ville ".$Ville;
  280. push @bloc, "\n";
  281. push @bloc, "Comparaison ".$Comparaison;
  282. push @bloc, "\n";
  283. push @bloc, "Mot-Outil ".$MotOutil;
  284. push @bloc, "\n";
  285. push @bloc, "Autre-Mots ".$AutreMots;
  286. push @bloc, "\n";
  287. push @bloc, "Autre ".$Autre;
  288. push @bloc, "\n";
  289. push @bloc, "Disponibilite ".$Disponibilite;
  290. push @bloc, "\n";
  291. push @bloc, "Nombre ".$Nombre;
  292. push @bloc, "\n";
  293. push @bloc, "Annees ".$Annees;
  294. push @bloc, "\n";
  295. push @bloc, "Moyen-Transport ".$MoyenTransport;
  296. push @bloc, "\n";
  297. push @bloc, "Action ".$Action;
  298. push @bloc, "\n";
  299. push @bloc, "Etat ".$Etat;
  300. push @bloc, "\n";
  301. push @bloc, "Certitude ".$Certitude;
  302. push @bloc, "\n";
  303. push @bloc, "Jure ".$Jure;
  304. push @bloc, "\n";
  305. push @bloc, "Demande ".$Demande;
  306. push @bloc, "\n";
  307. push @bloc, "Politesse ".$Politesse;
  308. push @bloc, "\n";
  309. push @bloc, "Outil-Question ".$OutilQuestion;
  310. push @bloc, "\n";
  311. push @bloc, "Lieu ".$Lieu;
  312. push @bloc, "\n";
  313. push @bloc, "Amorce ".$Amorce;
  314. push @bloc, "\n";
  315. push @bloc, "Salutation ".$Salutation;
  316. push @bloc, "\n";
  317. push @bloc, "Type-Train ".$TypeTrain;
  318. push @bloc, "\n";
  319. push @bloc, "Classe-Train ".$ClasseTrain;
  320. push @bloc, "\n";
  321. push @bloc, "Mois ".$Mois;
  322. push @bloc, "\n";
  323. push @bloc, "Jour ".$Jour;
  324. push @bloc, "\n";
  325. push @bloc, "Horaires ".$Horaires;
  326. push @bloc, "\n";
  327. push @bloc, "Nomination ".$Nomination;
  328. push @bloc, "\n";
  329. push @bloc, "Hesitation ".$Hesitation;
  330. push @bloc, "\n";
  331. push @bloc, "Reponse ".$Reponse;
  332. push @bloc, "\n";
  333. push @bloc, "Monnaie ".$Monnaie;
  334. push @bloc, "\n";
  335. push @bloc, "Pronom".$Pronom;
  336. push @bloc, "\n";
  337. push @bloc, "Quantite ".$Quantite;
  338. push @bloc, "\n";
  339. push @bloc, "Promotion ".$Promotion;
  340. push @bloc, "\n";
  341. push @bloc, "Billet ".$Billet;
  342. push @bloc, "\n";
  343. push @bloc, "Voyageur ".$Voyageur;
  344. push @bloc, "\n";
  345. push @bloc, "Carte ".$Carte;
  346. push @bloc, "\n";
  347. if (0+@bloc) {
  348. print $fh1 join("  ", @bloc), "\n";
  349. }


 
avec  
fic2.xml :
 
<mot>
<synonyme>أُصْرُفْ</synonyme>
<etiquette>Marqueur-Payement</etiquette>
</mot>
<mot>
<synonyme>نْخَلِّيكْ</synonyme>
<etiquette>Mot</etiquette>
</mot>
<mot>
<synonyme>تَرْجَعْلي</synonyme>
<etiquette>Mot</etiquette>
</mot>
 
 
fic3.xml  
<classe>
<nom>Certitude</nom>
<etiquette1>Incertitude</etiquette1>
<etiquette2>Certitude</etiquette2>
</classe>
 
 
<classe>
<nom>Jure</nom>
<etiquette1>Jure</etiquette1>
</classe>
 
 
<classe>
<nom>Reponse</nom>
<etiquette1>Confirmation</etiquette1>
<etiquette2>Negation</etiquette2>
<etiquette3>Reponse</etiquette3>
</classe>
 
 
et sortie2.txt :
 
تْفَضَّلْ
خُويَا
مْعَ
وَقْتَاشْ
بِاللهْ
التْرَانْ
يِمْشِي
مَاضِي
سَاعَةْ
وَ
أَرْبْعَةْ
مَا
ثَمَّاشْ
وَاحِدْ
 
 
 
 
mon but est faire un programme dont la sortie est la suivante :  
 
 
nom de classe mot1 mot2 mot3 ....

 
 
avec nom de classe est le nom de classe du fichier fic3.txt et word1 word2 etc sont le mots ds sortie.txt tout en utilisant la base fic2.xml
 
 
mon problème et que je constate qu'il ya des mots ds sortie2 qui non pas classé , peut etre c'est un problème des espaces  
 
 
 
 
 
 
 
 
 

n°2214426
rim_enis
j'aime ENIS
Posté le 25-12-2013 à 17:49:01  profilanswer
 

bonoir gilou ,
 
j'ai encore des problèmes avec perl , merci de m'aider SVP ,
 
voici mon programme perl :  
 

Code :
  1. use strict;
  2. use warnings;
  3. use autodie;
  4. use XML::TreeBuilder;
  5. my %h1;
  6. my $tree = XML::TreeBuilder->new();
  7. $tree->parse_file('/home/hp/Bureau/Master/fic2.xml');
  8. my @mots = $tree->find('mot');
  9. foreach (@mots) {
  10.         s/^\s+|\s+$//g;
  11.         next if (/^$/);
  12. my ($synonyme, $etiquette);
  13. foreach ($_->descendants()) {
  14.    my $tag = $_->tag();
  15.    if ($tag ~~ "synonyme" ) {
  16.      $synonyme = ($_->content_list())[0];
  17.         next if (ref($synonyme));
  18.         $synonyme =~ s/^\s+|\s+$//g;
  19.         next if ($synonyme ~~ /^$/);
  20.    }
  21.    if ($tag ~~ "etiquette" ) {
  22.      $etiquette = ($_->content_list())[0];
  23.     next if (ref($etiquette));
  24.         $etiquette =~ s/^\s+|\s+$//g;
  25.         next if ($etiquette ~~ /^$/);
  26.      $h1{$synonyme} = $etiquette;
  27.    }
  28. }
  29. }
  30. $tree->delete;
  31. my %h2;
  32. $tree = XML::TreeBuilder->new();
  33. $tree->parse_file('/home/hp/Bureau/Master/fic3.xml');
  34. my @classes = $tree->find('classe');
  35. foreach (@classes) {
  36. s/^\s+|\s+$//g;
  37.         next if (/^$/);
  38. #my $synonyme = $_->{'synonyme'};
  39.        # next if (ref($synonyme));
  40. my ($nom, $etiquette);
  41. foreach ($_->descendants()) {
  42.    my $tag = $_->tag();
  43.    if ($tag ~~ "nom" ) {
  44.      $nom = ($_->content_list())[0];
  45. next if (ref($nom));
  46.         $nom =~ s/^\s+|\s+$//g;
  47.         next if ($nom ~~ /^$/);
  48.    }
  49.    if ($tag ~~ /^etiquette\d+$/) {
  50.      $etiquette = ($_->content_list())[0];
  51. next if (ref($etiquette));
  52.         $etiquette =~ s/^\s+|\s+$//g;
  53.         next if ($etiquette ~~ /^$/);
  54.      $h2{$etiquette}= $nom;
  55.    }
  56. }
  57. }
  58. $tree->delete;
  59. open my $fh,  "<:utf8 ", '/home/hp/Bureau/Master/sortie2.txt';
  60. open my $fh1, ">:utf8", '/home/hp/Bureau/Master/sortie3.txt';
  61. my $linenum = 0;
  62. my (@bloc, @words);
  63. my $Appelation="";
  64. my $Obligation="";
  65. my $Ville="";
  66. my $Comparaison="";
  67. my $MotOutil="";
  68. my $AutreMots="";
  69. my $Autre="";
  70. my $Disponibilite="";
  71. my $Nombre="";
  72. my $Annees="";
  73. my $MoyenTransport="";
  74. my $Action="";
  75. my $Etat="";
  76. my $Certitude="";
  77. my $Jure="";
  78. my $Demande="";
  79. my $Politesse="";
  80. my $OutilQuestion="";
  81. my $Lieu="";
  82. my $Amorce="";
  83. my $Salutation="";
  84. my $TypeTrain="";
  85. my $ClasseTrain="";
  86. my $Mois="";
  87. my $Jour="";
  88. my $Horaires="";
  89. my $Nomination="";
  90. my $Hesitation="";
  91. my $Reponse="";
  92. my $Monnaie="";
  93. my $Pronom="";
  94. my $Quantite="";
  95. my $Promotion="";
  96. my $Billet="";
  97. my $Voyageur="";
  98. my $Carte="";
  99. my $Possibilite="";
  100.        
  101. foreach(<$fh> ) {
  102. unless ($linenum++ or not /^\x{feff}/) {
  103.    s/^\x{feff}// ;
  104. }
  105. if (/^\s*$/) {
  106.    if (0+@bloc) {
  107. #print $fh1 join(" ", @bloc), "\n";
  108.      @bloc = ();
  109.    }
  110. }
  111. else {
  112. chomp;
  113.    s/^\s+|\s+$//g;
  114.    @words = split /\s+/;
  115.    if (defined($h1{$words[0]}) and defined($h2{$h1{$words[0]}})) {
  116.  
  117. if ($h2{$h1{$words[0]}} ~~ "Appelation" ) {
  118.    
  119. $Appelation .= " $words[0]";
  120. }
  121. if ($h2{$h1{$words[0]}} ~~ "Obligation" ) {
  122.    
  123. $Obligation .= " $words[0]";
  124. if ($h2{$h1{$words[0]}} ~~ "Ville" ) {
  125.    
  126. $Ville .= " $words[0]";
  127. }
  128. if ($h2{$h1{$words[0]}} ~~ "Comparaison" ) {
  129.    
  130. $Comparaison .= " $words[0]";
  131. }
  132. if ($h2{$h1{$words[0]}} ~~ "Mot-Outil" ) {
  133.    
  134. $MotOutil .= " $words[0]";
  135. }
  136. if ($h2{$h1{$words[0]}} ~~ "Autre-Mots" ) {
  137.    
  138. $AutreMots .= " $words[0]";
  139. }
  140. if ($h2{$h1{$words[0]}} ~~ "Autre" ) {
  141.    
  142. $Autre .= " $words[0]";
  143. }
  144. if ($h2{$h1{$words[0]}} ~~ "Disponibilite" ) {
  145.    
  146. $Disponibilite .= " $words[0]";
  147. }
  148. if ($h2{$h1{$words[0]}} ~~ "Nombre" ) {
  149.    
  150. $Nombre .= " $words[0]";
  151. }
  152. if ($h2{$h1{$words[0]}} ~~ "Annees" ) {
  153.    
  154. $Annees .= " $words[0]";
  155. }
  156. if ($h2{$h1{$words[0]}} ~~ "Moyen-Transport" ) {
  157.    
  158. $MoyenTransport .= " $words[0]";
  159. }
  160. if ($h2{$h1{$words[0]}} ~~ "Possibilite" ) {
  161.    
  162. $Possibilite .= " $words[0]";
  163. if ($h2{$h1{$words[0]}} ~~ "Action" ) {
  164.    
  165. $Action .= " $words[0]";
  166. }
  167. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  168.    
  169. $Etat .= " $words[0]";
  170. }
  171. if ($h2{$h1{$words[0]}} ~~ "Certitude" ) {
  172.    
  173. $Certitude .= " $words[0]";
  174. }
  175. if ($h2{$h1{$words[0]}} ~~ "Jure" ) {
  176.    
  177. $Jure .= " $words[0]";
  178. }
  179. if ($h2{$h1{$words[0]}} ~~ "Demande" ) {
  180.    
  181. $Demande .= " $words[0]";
  182. }
  183. if ($h2{$h1{$words[0]}} ~~ "Politesse" ) {
  184.    
  185. $Politesse .= " $words[0]";
  186. }
  187. if ($h2{$h1{$words[0]}} ~~ "Outil-Question" ) {
  188.    
  189. $OutilQuestion .= " $words[0]";
  190. }
  191. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  192.    
  193. $Etat .= " $words[0]";
  194. }
  195. if ($h2{$h1{$words[0]}} ~~ "Etat" ) {
  196.    
  197. $Etat .= " $words[0]";
  198. }
  199. if ($h2{$h1{$words[0]}} ~~ "Lieu" ) {
  200.    
  201. $Lieu .= " $words[0]";
  202. }
  203. if ($h2{$h1{$words[0]}} ~~ "Amorce" ) {
  204.    
  205. $Amorce .= " $words[0]";
  206. }
  207. if ($h2{$h1{$words[0]}} ~~ "Salutation" ) {
  208.    
  209. $Salutation .= " $words[0]";
  210. }
  211. if ($h2{$h1{$words[0]}} ~~ "Type-Train" ) {
  212.    
  213. $TypeTrain .= " $words[0]";
  214. }
  215. if ($h2{$h1{$words[0]}} ~~ "Classe-Train" ) {
  216.    
  217. $ClasseTrain .= " $words[0]";
  218. }
  219. if ($h2{$h1{$words[0]}} ~~ "Mois" ) {
  220.    
  221. $Mois .= " $words[0]";
  222. }
  223. if ($h2{$h1{$words[0]}} ~~ "Jour" ) {
  224.    
  225. $Jour .= " $words[0]";
  226. }
  227. if ($h2{$h1{$words[0]}} ~~ "Horaires" ) {
  228.    
  229. $Horaires .= " $words[0]";
  230. }
  231. if ($h2{$h1{$words[0]}} ~~ "Nomination" ) {
  232.    
  233. $Nomination .= " $words[0]";
  234. }
  235. if ($h2{$h1{$words[0]}} ~~ "Hesitation" ) {
  236.    
  237. $Hesitation .= " $words[0]";
  238. }
  239. if ($h2{$h1{$words[0]}} ~~ "Reponse" ) {
  240.    
  241. $Reponse .= " $words[0]";
  242. }
  243. if ($h2{$h1{$words[0]}} ~~ "Monnaie" ) {
  244.    
  245. $Monnaie .= " $words[0]";
  246. }
  247. if ($h2{$h1{$words[0]}} ~~ "Pronom" ) {
  248.    
  249. $Pronom .= " $words[0]";
  250. }
  251.    
  252. }
  253. if ($h2{$h1{$words[0]}} ~~ "Quantite" ) {
  254.    
  255. $Quantite .= " $words[0]";
  256. }
  257. if ($h2{$h1{$words[0]}} ~~ "Promotion" ) {
  258.    
  259. $Promotion .= " $words[0]";
  260. }
  261. if ($h2{$h1{$words[0]}} ~~ "Billet" ) {
  262.    
  263. $Billet .= " $words[0]";
  264. }
  265. if ($h2{$h1{$words[0]}} ~~ "Voyageur" ) {
  266.    
  267. $Voyageur .= " $words[0]";
  268. }
  269. if ($h2{$h1{$words[0]}} ~~ "Carte" ) {
  270.    
  271. $Carte .= " $words[0]";
  272. }
  273. }
  274. }
  275. push @bloc, "  Appelation ".$Appelation;
  276. push @bloc, "\n";
  277. push @bloc, "Obligation ".$Obligation;
  278. push @bloc, "\n";
  279. push @bloc, "Ville ".$Ville;
  280. push @bloc, "\n";
  281. push @bloc, "Comparaison ".$Comparaison;
  282. push @bloc, "\n";
  283. push @bloc, "Mot-Outil ".$MotOutil;
  284. push @bloc, "\n";
  285. push @bloc, "Autre-Mots ".$AutreMots;
  286. push @bloc, "\n";
  287. push @bloc, "Autre ".$Autre;
  288. push @bloc, "\n";
  289. push @bloc, "Disponibilite ".$Disponibilite;
  290. push @bloc, "\n";
  291. push @bloc, "Nombre ".$Nombre;
  292. push @bloc, "\n";
  293. push @bloc, "Annees ".$Annees;
  294. push @bloc, "\n";
  295. push @bloc, "Moyen-Transport ".$MoyenTransport;
  296. push @bloc, "\n";
  297. push @bloc, "Action ".$Action;
  298. push @bloc, "\n";
  299. push @bloc, "Etat ".$Etat;
  300. push @bloc, "\n";
  301. push @bloc, "Certitude ".$Certitude;
  302. push @bloc, "\n";
  303. push @bloc, "Jure ".$Jure;
  304. push @bloc, "\n";
  305. push @bloc, "Demande ".$Demande;
  306. push @bloc, "\n";
  307. push @bloc, "Politesse ".$Politesse;
  308. push @bloc, "\n";
  309. push @bloc, "Outil-Question ".$OutilQuestion;
  310. push @bloc, "\n";
  311. push @bloc, "Lieu ".$Lieu;
  312. push @bloc, "\n";
  313. push @bloc, "Amorce ".$Amorce;
  314. push @bloc, "\n";
  315. push @bloc, "Salutation ".$Salutation;
  316. push @bloc, "\n";
  317. push @bloc, "Type-Train ".$TypeTrain;
  318. push @bloc, "\n";
  319. push @bloc, "Classe-Train ".$ClasseTrain;
  320. push @bloc, "\n";
  321. push @bloc, "Mois ".$Mois;
  322. push @bloc, "\n";
  323. push @bloc, "Jour ".$Jour;
  324. push @bloc, "\n";
  325. push @bloc, "Horaires ".$Horaires;
  326. push @bloc, "\n";
  327. push @bloc, "Nomination ".$Nomination;
  328. push @bloc, "\n";
  329. push @bloc, "Hesitation ".$Hesitation;
  330. push @bloc, "\n";
  331. push @bloc, "Reponse ".$Reponse;
  332. push @bloc, "\n";
  333. push @bloc, "Monnaie ".$Monnaie;
  334. push @bloc, "\n";
  335. push @bloc, "Pronom".$Pronom;
  336. push @bloc, "\n";
  337. push @bloc, "Quantite ".$Quantite;
  338. push @bloc, "\n";
  339. push @bloc, "Promotion ".$Promotion;
  340. push @bloc, "\n";
  341. push @bloc, "Billet ".$Billet;
  342. push @bloc, "\n";
  343. push @bloc, "Voyageur ".$Voyageur;
  344. push @bloc, "\n";
  345. push @bloc, "Carte ".$Carte;
  346. push @bloc, "\n";
  347. if (0+@bloc) {
  348. print $fh1 join("  ", @bloc), "\n";
  349. }


 
avec  
fic2.xml :
 
<mot>
<synonyme>أُصْرُفْ</synonyme>
<etiquette>Marqueur-Payement</etiquette>
</mot>
<mot>
<synonyme>نْخَلِّيكْ</synonyme>
<etiquette>Mot</etiquette>
</mot>
<mot>
<synonyme>تَرْجَعْلي</synonyme>
<etiquette>Mot</etiquette>
</mot>
 
 
fic3.xml  
<classe>
<nom>Certitude</nom>
<etiquette1>Incertitude</etiquette1>
<etiquette2>Certitude</etiquette2>
</classe>
 
 
<classe>
<nom>Jure</nom>
<etiquette1>Jure</etiquette1>
</classe>
 
 
<classe>
<nom>Reponse</nom>
<etiquette1>Confirmation</etiquette1>
<etiquette2>Negation</etiquette2>
<etiquette3>Reponse</etiquette3>
</classe>
 
 
et sortie2.txt :
 
تْفَضَّلْ
خُويَا
مْعَ
وَقْتَاشْ
بِاللهْ
التْرَانْ
يِمْشِي
مَاضِي
سَاعَةْ
وَ
أَرْبْعَةْ
مَا
ثَمَّاشْ
وَاحِدْ
 
 
 
 
mon but est faire un programme dont la sortie est la suivante :  
 
 
nom de classe mot1 mot2 mot3 ....

 
 
avec nom de classe est le nom de classe du fichier fic3.txt et word1 word2 etc sont le mots ds sortie.txt tout en utilisant la base fic2.xml
 
 
mon problème et que je constate qu'il ya des mots ds sortie2 qui non pas classé , peut etre c'est un problème des espaces  
 
 
 
 
 
 
 
 
 

mood
Publicité
Posté le   profilanswer
 

 Page :   1  2
Page Suivante

Aller à :
Ajouter une réponse
 

Sujets relatifs
recherche expert en PERLcomparaison date
[PERL] SubtitionSockets en Perl
[PERL] Récupérer des données dans un fichier txtComparaison avec drawLine ?!
Comparaison et calculs sur deux fichiers à la foisHelp comparaison de deux fichier perl
[Perl - Débutant]Probleme de comparaison de 2 chaines[Perl] Comment ignorer la casse dans une comparaison ?
Plus de sujets relatifs à : perl + comparaison + xml


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR