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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
| int main(int argc, char *argv[])
{
TraiterFichBinaire();
return 0;
}
void TraiterFichBinaire ()
{
const char* MotFR="table1MotFR.bin";
const char* MotEN="table1MotEn.bin";
const char* SeqFR="table2MotFR.bin";
const char* SeqEN="table2MotEn.bin";
struct TableHachage_BiSequence* TH_FR;
struct TableHachage_BiSequence* TH_EN;
// Ces variables sont pour les sequences
struct char_fbtAllocator *pAllocCaracsFR_seq=NULL, *pAllocCaracsEN_seq=NULL;
struct int_fbtAllocator *pAllocLignesFR_seq=NULL, *pAllocLignesEN_seq=NULL;
size_t *pTaillesTableFR_seq=NULL,*pTaillesTableEN_seq=NULL;
size_t nbCaracsFR_seq=0, nbCaracsEN_seq=0, nbSeqFR=0,nbSeqEN=0;
unsigned int nbLignesFR_seq=0,nbLignesEN_seq=0;
MotCompact * pSeqFR = NULL;
MotCompact * pSeqEN = NULL;
// Ces variables sont pour les mots (gauches et droits)
struct char_fbtAllocator *pAllocCaracsFR_mots=NULL, *pAllocCaracsEN_mots=NULL;
struct int_fbtAllocator *pAllocLignesFR_mots=NULL, *pAllocLignesEN_mots=NULL;
size_t *pTaillesTableFR_mots=NULL,*pTaillesTableEN_mots=NULL;
size_t nbCaracsFR_mots=0, nbCaracsEN_mots=0, nbMotsFR=0,nbMotsEN=0;
unsigned int nbLignesFR_mots=0,nbLignesEN_mots=0;
MotCompact * pMotsFR = NULL;
MotCompact * pMotsEN = NULL;
// Chargement des sequences (FR et EN)
if (CompterToutesTablesFichBinaire2(SeqFR,&nbSeqFR, &nbCaracsFR_seq, &nbLignesFR_seq)<0)
{
goto LNettoyage;
}
if (CompterToutesTablesFichBinaire2(SeqEN,&nbSeqEN, &nbCaracsEN_seq, &nbLignesEN_seq)<0)
{
goto LNettoyage;
}
pAllocCaracsFR_seq = char_CreateFbtAllocator(nbCaracsFR_seq);
pAllocCaracsEN_seq= char_CreateFbtAllocator(nbCaracsEN_seq);
if (pAllocCaracsFR_seq==NULL || pAllocCaracsEN_seq==NULL)
{
goto LNettoyage;
}
pAllocLignesFR_seq = int_CreateFbtAllocator(nbLignesFR_seq);
pAllocLignesEN_seq = int_CreateFbtAllocator(nbLignesEN_seq);
if ( pAllocLignesFR_seq==NULL|| pAllocLignesEN_seq==NULL)
{
goto LNettoyage;
}
printf("%d",nbSeqFR);
pSeqFR = LireToutesTablesFichBinaire(SeqFR,nbSeqFR, pAllocCaracsFR_seq, pAllocLignesFR_seq);
pSeqEN = LireToutesTablesFichBinaire(SeqEN,nbSeqEN, pAllocCaracsEN_seq, pAllocLignesEN_seq);
if (pSeqFR==NULL|| pSeqEN==NULL)
{
DetruireTableauMotsCompacts(pSeqFR), pSeqFR=NULL;
DetruireTableauMotsCompacts(pSeqEN), pSeqEN=NULL;
goto LNettoyage;
}
// Chargement des mots (gauches et droites) (FR et EN)
if (CompterToutesTablesFichBinaire2(MotFR,&nbMotsFR, &nbCaracsFR_mots, &nbLignesFR_mots)<0)
{
goto LNettoyage;
}
if (CompterToutesTablesFichBinaire2(MotEN,&nbMotsEN, &nbCaracsEN_mots, &nbLignesEN_mots)<0)
{
goto LNettoyage;
}
pAllocCaracsFR_mots = char_CreateFbtAllocator(nbCaracsFR_mots);
pAllocCaracsEN_mots = char_CreateFbtAllocator(nbCaracsEN_mots);
if (pAllocCaracsFR_mots == NULL || pAllocCaracsEN_mots == NULL)
{
goto LNettoyage;
}
pAllocLignesFR_mots = int_CreateFbtAllocator(nbLignesFR_mots);
pAllocLignesEN_mots = int_CreateFbtAllocator(nbLignesEN_mots);
if ( pAllocLignesFR_mots == NULL || pAllocLignesEN_mots == NULL)
{
goto LNettoyage;
}
pMotsFR = LireToutesTablesFichBinaire(MotFR,nbMotsFR, pAllocCaracsFR_mots, pAllocLignesFR_mots);
pMotsEN = LireToutesTablesFichBinaire(MotEN,nbMotsEN, pAllocCaracsEN_mots, pAllocLignesEN_mots);
if (pMotsFR==NULL|| pMotsEN==NULL)
{
DetruireTableauMotsCompacts(pMotsFR), pMotsFR=NULL;
DetruireTableauMotsCompacts(pMotsEN), pMotsEN=NULL;
goto LNettoyage;
}
TH_FR=CreerSimpleTableHachage();
TH_EN=CreerSimpleTableHachage();
printf("Remplissage de la table de hachage\n");
RemplirTableHachageSeq(pSeqFR, TH_FR,nbSeqEN);
TrieTable(TH_FR);
DumpTable(TH_FR);
RemplirTableHachageMots(pMotsFR, TH_FR,nbMotsFR);
RemplirTableHachageSeq(pSeqEN, TH_EN,nbSeqEN);
TrieTable(TH_EN);
RemplirTableHachageMots(pMotsEN, TH_EN,nbMotsEN);
printf("calcul des regles");
GenererRegle2FR1EN(TH_FR,pMotsEN,nbMotsEN);
DetruireTableauMotsCompacts(pSeqFR), pSeqFR=NULL;
DetruireTableauMotsCompacts(pSeqEN), pSeqEN=NULL;
DetruireTableauMotsCompacts(pMotsFR), pMotsFR=NULL;
DetruireTableauMotsCompacts(pMotsEN), pMotsEN=NULL;
LNettoyage:
free(pTaillesTableFR_seq), pTaillesTableFR_seq=NULL;
free(pTaillesTableEN_seq), pTaillesTableEN_seq=NULL;
free(pTaillesTableFR_mots), pTaillesTableFR_mots=NULL;
free(pTaillesTableEN_mots), pTaillesTableEN_mots=NULL;
} |
Partager