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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
#!/usr/bin/perl
use XML::Twig;
use File::Spec;
#-----------------------------------------------------------
# MAIN
#-----------------------------------------------------------
#Déclaration des fichiers Xml:
my $goodFileXML = 'D:\\Memoire Mastere\\Script\\Script_final\\Script_Grapheme-phoneme\\output.xml';
my $goodFileXML1 = 'D:\\Memoire Mastere\\Script\\Script_final\\Script_Grapheme-phoneme\\RegleDePhonetisation.xml';
my $goodFileXML2 = 'D:\\Memoire Mastere\\Script\\Script_final\\Script_Grapheme-phoneme\\BaseException.xml';
#Déclaration du fichier résultat
my $RepBase = 'D:\\Memoire Mastere\\Script\\Script_final\\Script_Grapheme-phoneme';
my $FicAraOut1 = File::Spec->catfile( $RepBase, 'outregless.txt' );
open (OUT_Aran, '+>:encoding(UTF-8)', $FicAraOut1 ) or die "Impossible ouvrir fichier $FicAraOut1 en sortie\n";
#Tableau qui contient tous les caractéres des mots du fichier output.xml
@tabcar=();
$size=scalar(@tabcar);
$i,$j;
#Tableau qui contient tous les types des caractéres des mots du fichier Output.xml
@tabtype=();
$sizes=scalar(@tabtype);
#Tableau qui contient tous les régles du fichier RegleDePhonetisation.xml
@tabregle=();
$sizer=scalar(@tabregle);
#Tableau qui contient tous les régles du fichier RegleDePhonetisation.xml
@tabexcep=();
$sizee=scalar(@tabexcep);
print OUT_Aran "Grapheme :"," Phoneme : \n";
#Appel des fonctions
my $twig = new XML::Twig( Twig_handlers => { 'Mot' => \&Mot, }, );
print "Output.xml \n";
$twig->parsefile($goodFileXML);
@tabout=<OUT_Aran>;
$size1 = scalar(@tabout);
#-----------------------------------------------------------#
# *********************Fonctions********************** #
#-----------------------------------------------------------#
#-----------------------------------------------------------
# On récupére les données du Output.xml
#-----------------------------------------------------------
sub Mot
{
my $twig2= new XML::Twig;
$twig2->parsefile($goodFileXML2);
my $root= $twig2->root;
my @Exception= $root->children;
my $twig3= new XML::Twig;
$twig3->parsefile($goodFileXML1);
my $root3= $twig3->root;
my @regle= $root3->children;
($twig,$mot)= @_;
foreach $TwmotFils( $mot->att('Nom'))
{
foreach $Exception (@Exception)
{
if ($TwmotFils eq $Exception->first_child('Grapheme')->text())
{
print "comapraison:",$e,"\n";
print OUT_Aran $mot->att('Nom')," ",$Exception->first_child('Phoneme')->text(),"\n";
}
}
}
print OUT_Aran $mot->att('Nom'),"\n";
foreach $TwmotFils( $mot->att('Nom'))
{
foreach $TwcarFils ($mot->children('caractere'))
{
foreach $regle (@regle)
{
foreach $TwregleFils ($regle->children('Composant'))
{
if ($TwregleFils->att('Nom') eq "Graph")
{
if ($TwregleFils->text() eq $TwcarFils->text())
{
print "Coprs du boucle if 2 \n";
@tabregle=($TwcarFils->text());
@tab=($regle->last_child('Composant')->text());
}
}
}
}
}
}
for $i (0..$sizer)
{
print OUT_Aran $tabregle[$i]," ";
}
for $j (0..$#tab)
{
print OUT_Aran $tab[$j]," ";
}
print OUT_Aran "\n";
print "fin du fonction regle\n";
} |
Partager