Commit 3b61598efc032cd889dcd72a2a1527a251766dc9

Authored by pvernier
2 parents 6d231301 ee3fc0eb

Merge branch 'master' of https://archives.plil.fr/pvernier/ima3_projet_pa_2019

dicoesp.txt 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +México o Méjico es un país en América del Norte América del Norte es un continente México está al sur de los Estados Unidos y al norte de Guatemala y de Belice Al este de México hay el golfo de México y al oeste hay el océano Pacífico
  2 +niño
  3 +Los habitantes de México se llaman Mexicanos o Mejicanos Hay 107 000 000 de habitantes en el país La capital es México o México Distrito Federal La capital es una gran ciudad Hay de habitantes en la capital Es una de las ciudades más grandes del mundo
0 4 \ No newline at end of file
... ...
projetfinalaccent2.c
... ... @@ -3,7 +3,7 @@
3 3 #include <wchar.h>
4 4 #include <locale.h>
5 5  
6   -#define A 256
  6 +#define A 259
7 7  
8 8 struct node {
9 9 wchar_t lettre;
... ... @@ -15,20 +15,19 @@ struct cell {
15 15 struct cell* arbreSuivant;
16 16 };
17 17  
18   -void lien_listeFils(struct cell** pL) {
19   - struct cell* p;
20   - p = malloc(sizeof(struct cell));
21   -
22   - (*pL)->arbre->listeFils = p;
23   -}
24   -
25 18 void initialisation_tab_arbre(struct node tab[]) {
26 19 int i = 0;
27   - for(wchar_t u = 'a'; u < A; u++) {
  20 + for(wchar_t u = 'a'; u < A-3; u++) {
28 21 tab[i].lettre = u; //ajout lettres minuscules
29 22 tab[i].listeFils = NULL;
30 23 i++;
31 24 }
  25 + tab[A-3].lettre = '?';
  26 + tab[A-2].lettre = '!';
  27 + tab[A-1].lettre = '\'';
  28 + tab[A-3].listeFils = NULL;
  29 + tab[A-2].listeFils = NULL;
  30 + tab[A-1].listeFils = NULL;
32 31 }
33 32  
34 33 void ajout_tete(wchar_t elem, struct cell** pL) {
... ... @@ -82,7 +81,7 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
82 81 else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
83 82 localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
84 83 }
85   - else if(motLu[0] > 'z') {
  84 + else if((motLu[0] < 'A') || (motLu[0] > 'z')) {
86 85 indice = indice_lettre(tab_arbre_prcp, motLu[0]);
87 86 localisationArbre = &tab_arbre_prcp[indice].listeFils;
88 87 if(indice == 0) {
... ... @@ -98,7 +97,6 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
98 97 }
99 98 while((motLu[i] != '\0') && (estUneLettre == 1)) {
100 99 i += 1;
101   - //wprintf(L"lettre lue %d\n", motLu[i]);
102 100 localisationArbre = insertion(motLu[i], localisationArbre);
103 101 }
104 102 }
... ... @@ -107,7 +105,7 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
107 105 wprintf(L"%d mots inseres dans le dictionnaire.\n", cptmot);
108 106 }
109 107  
110   -struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) {
  108 +struct cell ** test_mot(wchar_t mot, struct cell** localisation, int* verif) {
111 109  
112 110 if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) {
113 111 *verif = 0;
... ... @@ -124,7 +122,7 @@ struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) {
124 122 void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
125 123 struct cell** localisationArbre = NULL;
126 124 int verif;
127   - int indice = 0;
  125 + int indice = 0, cptfaute = 0;
128 126 wchar_t motLu[50];
129 127 while(fwscanf(fd, L"%ls", motLu)==1) {
130 128 verif = 1;
... ... @@ -135,11 +133,12 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
135 133 else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
136 134 localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
137 135 }
138   - else if(motLu[0] > 'z') {
  136 + else if((motLu[0] < 'A') || (motLu[0] > 'z')) {
  137 + printf("jsuisla\n");
139 138 indice = indice_lettre(tab_arbre_prcp, motLu[0]);
140 139 localisationArbre = &tab_arbre_prcp[indice].listeFils;
141 140 if(indice == 0) {
142   - wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n");
  141 + wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n");
143 142 verif = 0;
144 143 }
145 144 }
... ... @@ -149,10 +148,15 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
149 148 }
150 149 while((verif == 1) && (motLu[i] != '\0')) {
151 150 i += 1;
  151 + if((motLu[i] == '.') || (motLu[i] == ',') || (motLu[i] == ';') || (motLu[i] == ':') || (motLu[i] == '!') || (motLu[i] == '?')) motLu[i] = '\0'; //prendre en compte les fins de phrase
152 152 localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
153 153 }
154   - if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu);
  154 + if(verif == 0) {
  155 + wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu);
  156 + cptfaute += 1;
  157 + }
155 158 }
  159 + printf("Le texte comporte %d faute(s)\n", cptfaute);
156 160 fclose(fd);
157 161 }
158 162  
... ... @@ -172,7 +176,7 @@ void correction_mot(struct node tab_arbre_prcp[]) {
172 176 else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
173 177 localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
174 178 }
175   - else if(motLu[0] > 'z') {
  179 + else if((motLu[0] < 'A') || (motLu[0] > 'z')) {
176 180 indice = indice_lettre(tab_arbre_prcp, motLu[0]);
177 181 localisationArbre = &tab_arbre_prcp[indice].listeFils;
178 182 if(indice == 0) {
... ... @@ -186,28 +190,23 @@ void correction_mot(struct node tab_arbre_prcp[]) {
186 190 }
187 191 while((verif == 1) && (motLu[i] != '\0')) {
188 192 i += 1;
  193 + if((motLu[i] == '.') || (motLu[i] == ',') || (motLu[i] == ';') || (motLu[i] == ':') || (motLu[i] == '!') || (motLu[i] == '?')) motLu[i] = '\0';
189 194 wprintf(L"lettre lue %d\n", motLu[i]);
190 195 localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
191 196 }
192   - if(verif == 0) wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu);
  197 + if(verif == 0) {
  198 + wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu);
  199 + }
193 200 else wprintf(L"Mot : %ls correct\n", motLu);
194 201 }
195 202 }
196 203  
197   -/*void supp_tete(struct cell** pL) {
198   - struct cell* p;
199   - p = *pL;
200   - *pL = (*pL) -> arbreSuivant;
201   - free(p);
202   -}*/
203   -
204 204 void desalocationArbre(struct cell** pL) {
205 205  
206 206 if ((*pL) == NULL) return;
207 207  
208 208 desalocationArbre(&(*pL)-> arbreSuivant);
209 209 desalocationArbre(&(*pL)-> arbre -> listeFils);
210   -
211 210 free((*pL) -> arbre);
212 211 free(*pL);
213 212 }
... ... @@ -215,9 +214,7 @@ void desalocationArbre(struct cell** pL) {
215 214 void desalocationTableauArbre(struct node tab_arbre[]){
216 215 int i = 0;
217 216 for(wchar_t u = 'a'; u < A; u++) {
218   -
219   - desalocationArbre(&tab_arbre[i].listeFils);
220   -
  217 + desalocationArbre(&tab_arbre[i].listeFils);
221 218 i++;
222 219 }
223 220 }
... ... @@ -229,7 +226,6 @@ int main(int argc, char* argv[]) {
229 226 FILE* dico = NULL;
230 227 FILE* txt = NULL;
231 228 struct node tab_arbre[A];
232   - //struct node * a;
233 229  
234 230 if(argc>2) {
235 231 dico = fopen(argv[1], "r");
... ... @@ -245,6 +241,7 @@ int main(int argc, char* argv[]) {
245 241 }
246 242 initialisation_tab_arbre(tab_arbre);
247 243 remplir_dico(dico, tab_arbre); //on suppose qu'il n'y a pas d'accents dans le dictionnaire
  244 + for(int i = 0; i < A; i++) wprintf(L"%lc\n", tab_arbre[i].lettre);
248 245 correction_txt(txt, tab_arbre);
249 246 correction_mot(tab_arbre);
250 247 desalocationTableauArbre(tab_arbre);
... ...
projetfinalaccent2.exe 0 → 100644
No preview for this file type
texte.txt
1   -paul
2   -arbre Tanguy
3   -feuilles
4   -vapeur
5   -abricots
6   -abricot
7   -agen
8   -feuil
  1 +He mustn't drink.
  2 +Three man went into a pub. They were all drunk and two of them were carring the third beetwen them. When they was inside they dropped him on the flor. Then they went in the bar.
  3 +They said to the barman, two whiskies, please.
  4 +The barman said, what about your frend ? Doesn't he wants an whisky?
  5 +Oh, no, they said,he mustn't drink. He's diving.
9 6 \ No newline at end of file
... ...
words.txt
1   -A
  1 +A
2 2 A's
3 3 AA's
4 4 AB's
... ...