Commit 3cc6463a9c5d5e9344cca2483a005a0480de0e33

Authored by tvieuble
1 parent 3f44e562

Suppression fichier inutile

Showing 1 changed file with 0 additions and 342 deletions   Show diff stats
projetfinalwchar_t.c deleted
... ... @@ -1,342 +0,0 @@
1   -#include <stdio.h>
2   -#include <stdlib.h>
3   -#include <wchar.h>
4   -#include <locale.h>
5   -
6   -#define A 26
7   -
8   -struct node {
9   - wchar_t lettre;
10   - struct cell* listeFils;
11   -};
12   -
13   -struct cell {
14   - struct node* arbre;
15   - struct cell* arbreSuivant;
16   -};
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   -void initialisation_tab_arbre(struct node tab[]) {
26   - for(int i = 0; i < A; i++) {
27   - tab[i].lettre = 97+i; //ajout lettres minuscules
28   - tab[i].listeFils = NULL;
29   - }
30   -}
31   -
32   -void ajout_tete(wchar_t elem, struct cell** pL) {
33   - struct cell* p;
34   - p = malloc(sizeof(struct cell));
35   - p->arbre = malloc(sizeof(struct node));
36   - p->arbre->listeFils = NULL;
37   - p->arbre->lettre = elem;
38   - p->arbreSuivant = *pL;
39   - *pL = p;
40   -}
41   -
42   -struct cell ** insertion(wchar_t elem, struct cell** pL) {
43   - if(((*pL) == NULL) || ((*pL)->arbre->lettre > elem)) {
44   - ajout_tete(elem, pL);
45   - return &(*pL)->arbre->listeFils;
46   - }
47   - else if((*pL)->arbre->lettre == elem) {
48   - return &(*pL)->arbre->listeFils;
49   - }
50   - else {
51   - return insertion(elem, &(*pL)->arbreSuivant);
52   - }
53   -}
54   -
55   -wchar_t conversion_accent(wchar_t lettre) { // Conversion Unicode -> ASCII 256
56   - switch(lettre) {
57   - case 192 : //ร€
58   - lettre = 182;
59   - break;
60   - case 193 : //ร
61   - lettre = 181;
62   - break;
63   - case 194 : //ร‚
64   - lettre = 182;
65   - break;
66   - case 198 : //ร†
67   - lettre = 146;
68   - break;
69   - case 199 : //ร‡
70   - lettre = 128;
71   - break;
72   - case 200 : //รˆ
73   - lettre = 212;
74   - break;
75   - case 201 : //ร‰
76   - lettre = 144;
77   - break;
78   - case 202 : //รŠ
79   - lettre = 210;
80   - break;
81   - case 203 : //ร‹
82   - lettre = 211;
83   - break;
84   - case 204 : //รŒ
85   - lettre = 141;
86   - break;
87   - case 205 : //ร
88   - lettre = 214;
89   - break;
90   - case 206 : //รŽ
91   - lettre = 215;
92   - break;
93   - case 207 : //ร
94   - lettre = 216;
95   - break;
96   - case 209 : //ร‘
97   - lettre = 165;
98   - break;
99   - case 210 : //ร’
100   - lettre = 227;
101   - break;
102   - case 211 : //ร“
103   - lettre = 224;
104   - break;
105   - case 212 : //ร”
106   - lettre = 226;
107   - break;
108   - /* case 140 : //ล’
109   - lettre =
110   - break;*/
111   - case 217 : //ร™
112   - lettre = 235;
113   - break;
114   - case 218 : //รš
115   - lettre = 233;
116   - break;
117   - case 219 : //ร›
118   - lettre = 234;
119   - break;
120   - case 220 : //รœ
121   - lettre = 154;
122   - break;
123   - case 221 : //ร
124   - lettre = 237;
125   - break;
126   - /*case 159 : //ลธ
127   - lettre =
128   - break;*/
129   - case 224 : //ร 
130   - lettre = 233;
131   - break;
132   - case 225 : //รก
133   - lettre = 160;
134   - break;
135   - case 226 : //รข
136   - lettre = 131;
137   - break;
138   - case 230 : //รฆ
139   - lettre = 145;
140   - break;
141   - case 231 : //รง
142   - lettre = 135;
143   - break;
144   - case 232 : //รจ
145   - lettre = 138;
146   - break;
147   - case 233 : //รฉ
148   - lettre = 130;
149   - break;
150   - case 234 : //รช
151   - lettre = 136;
152   - break;
153   - case 235 : //รซ
154   - lettre = 137;
155   - break;
156   - case 236 : //รฌ
157   - lettre = 141;
158   - break;
159   - case 237 : //รญ
160   - lettre = 161;
161   - break;
162   - case 238 : //รฎ
163   - lettre = 140;
164   - break;
165   - case 239 : //รฏ
166   - lettre = 139;
167   - break;
168   - case 241 : //รฑ
169   - lettre = 164;
170   - break;
171   - case 242 : //รฒ
172   - lettre = 149;
173   - break;
174   - case 243 : //รณ
175   - lettre = 162;
176   - break;
177   - case 244 : //รด
178   - lettre = 147;
179   - break;
180   - /*case 156 : //ล“
181   - lettre =
182   - break;*/
183   - case 249 : //รน
184   - lettre = 151;
185   - break;
186   - case 250 : //รบ
187   - lettre = 163;
188   - break;
189   - case 251 : //รป
190   - lettre = 150;
191   - break;
192   - /*case 252 : //รผ
193   - lettre =
194   - break;*/
195   - case 253 : //รฝ
196   - lettre = 263;
197   - break;
198   - case 255 : //รฟ
199   - lettre = 152;
200   - break;
201   - default :
202   - break;
203   - }
204   - return lettre;
205   -}
206   -
207   -void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) {
208   -
209   - struct cell** localisationArbre = NULL;
210   - int cptmot = 0;
211   - wchar_t motLu[50];
212   - while(fwscanf(fd, L"%ls", motLu)==1) {
213   - wprintf(L"mot lu : %ls\n", motLu);
214   - int wchar_tEstUneLettre = 1;
215   - int i = 0;
216   - cptmot += 1;
217   - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {
218   - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;
219   - }
220   - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
221   - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
222   - }
223   - else {
224   - wprintf(L"Erreur remplissage dico : L'un des caracteres n'est pas une lettre\n");
225   - wprintf(L"Mot : %ls incorrect\n", motLu);
226   - wchar_tEstUneLettre = 0;
227   - }
228   - while((motLu[i] != '\0') && (wchar_tEstUneLettre == 1)) {
229   - i += 1;
230   - wprintf(L"lettre lue %ld\n", motLu[i]);
231   - if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]);
232   - wprintf(L"lettre lue apres convversion : %ld\n", motLu[i]);}
233   - localisationArbre = insertion(motLu[i], localisationArbre);
234   - }
235   - wprintf(L"mot lu 2: %ls\n", motLu);
236   - }
237   - wprintf(L"\n");
238   - fclose(fd);
239   - wprintf(L"%d mots inseres dans le dictionnaire.\n", cptmot);
240   -}
241   -
242   -struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) {
243   -
244   - if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) {
245   - *verif = 0;
246   - return NULL;
247   - }
248   - if((*localisation)->arbre->lettre == mot) {
249   - return &(*localisation)->arbre->listeFils;
250   - }
251   - else {
252   - return test_mot(mot, &(*localisation)->arbreSuivant, verif);
253   - }
254   -}
255   -
256   -void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) {
257   - struct cell** localisationArbre = NULL;
258   - int verif;
259   - wchar_t motLu[50];
260   - while(fwscanf(fd, L"%ls", motLu)==1) {
261   - wprintf(L"mot lu : %ls\n", motLu);
262   - verif = 1;
263   - int i = 0;
264   - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {
265   - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;
266   - }
267   - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
268   - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
269   - }
270   - else {
271   - wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n");
272   - verif = 0;
273   - }
274   - while((verif == 1) && (motLu[i] != '\0')) {
275   - i += 1;
276   - if(motLu[i] > 127) {motLu[i] = conversion_accent(motLu[i]);
277   - wprintf(L"mot lu 2 : %ls\n", motLu);}
278   - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
279   - wprintf(L"lettre lue %ld\n", motLu[i]);
280   - }
281   - wprintf(L"\n");
282   - if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu);
283   -
284   - }
285   - fclose(fd);
286   -}
287   -
288   -void correction_mot(struct node tab_arbre_prcp[]) {
289   - struct cell** localisationArbre = NULL;
290   - int verif;
291   - wchar_t motLu[50];
292   - wprintf(L"Entrez un mot ou une phrase a corriger : \n(0 pour quitter)\n");
293   - while(wscanf(L"%ls", motLu)==1) {
294   - if(motLu[0]=='0') return;
295   - verif = 1;
296   - int i = 0;
297   - if((motLu[0] >= 'A') && (motLu[0] <= 'Z')) {
298   - localisationArbre = &tab_arbre_prcp[motLu[0]-65].listeFils;
299   - }
300   - else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) {
301   - localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils;
302   - }
303   - else {
304   - wprintf(L"Erreur correction mot : L'un des caract%lcres n'est pas une lettre\n", 130);
305   - verif = 0;
306   - }
307   - while((verif == 1) && (motLu[i] != '\0')) {
308   - i += 1;
309   - wprintf(L"lettre lue %ld\n", motLu[i]);
310   - localisationArbre = test_mot(motLu[i], localisationArbre, &verif);
311   - }
312   - if(verif == 0) wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu);
313   - else wprintf(L"Mot : %ls correct\n", motLu);
314   - }
315   -}
316   -
317   -
318   -int main(int argc, char* argv[]) {
319   -
320   - FILE* dico = NULL;
321   - FILE* txt = NULL;
322   - struct node tab_arbre[A];
323   -
324   - if(argc>2) {
325   - dico = fopen(argv[1], "r");
326   - txt = fopen(argv[2], "r");
327   - }
328   - else {
329   - dico = NULL;
330   - txt = NULL;
331   - }
332   - if ((dico == NULL) || (txt == NULL)) {
333   - wprintf(L"Erreur : il manque un ou plusieurs fichiers !\n");
334   - return 1;
335   - }
336   - initialisation_tab_arbre(tab_arbre);
337   - remplir_dico(dico, tab_arbre); //on suppose qu'il n'y a pas d'accents dans le dictionnaire
338   - correction_txt(txt, tab_arbre);
339   - correction_mot(tab_arbre);
340   -
341   - return 0;
342   -}