Commit 1ca5667ac671007e43dfb9da93b912a4dc7c199c
1 parent
3d38a257
Rapport
Showing
8 changed files
with
53 additions
and
180 deletions
Show diff stats
No preview for this file type
PROJET.odt
No preview for this file type
PROJET.pdf
No preview for this file type
README.md
projetV2.c
1 | -<<<<<<< HEAD | |
2 | 1 | #include <stdio.h> |
3 | 2 | #include <string.h> |
4 | 3 | #include <stdlib.h> |
... | ... | @@ -24,6 +23,17 @@ int num(char c){ |
24 | 23 | return -1; |
25 | 24 | } |
26 | 25 | |
26 | +struct cell * creation_cell (){ | |
27 | + struct cell * tmp ; | |
28 | + int i=0; | |
29 | + tmp=malloc(sizeof(struct cell)); | |
30 | + tmp->stop=0; | |
31 | + for (i=0;i<26;i++){ | |
32 | + tmp->liste[i]=NULL; | |
33 | + } | |
34 | + return tmp; | |
35 | +} | |
36 | + | |
27 | 37 | int ajout_mot(struct cell ** d,char * m){ |
28 | 38 | char c; |
29 | 39 | struct cell **tmp1 , *tmp2 ; |
... | ... | @@ -34,7 +44,7 @@ int ajout_mot(struct cell ** d,char * m){ |
34 | 44 | while (c != '\0'){ |
35 | 45 | //printf("%c",c); |
36 | 46 | if ((*tmp1)->liste[num(c)]==NULL){ |
37 | - tmp2=malloc(sizeof(struct cell)); | |
47 | + tmp2=creation_cell(); | |
38 | 48 | (*tmp1)->liste[num(c)]=tmp2; |
39 | 49 | } |
40 | 50 | tmp1=&((*tmp1)->liste[num(c)]); |
... | ... | @@ -78,14 +88,14 @@ int comparaison(char *m , int x , int conjug){ |
78 | 88 | return 0; |
79 | 89 | } |
80 | 90 | |
81 | -int reconaissance(struct cell * d,char * m){ | |
91 | +int reconaissance(struct cell * d,char * m , int conjug){ | |
82 | 92 | char c; |
83 | 93 | struct cell *tmp1; |
84 | 94 | int x=0; |
85 | 95 | tmp1=d; |
86 | 96 | if (d==NULL){return 1;} |
87 | 97 | c=m[x]; |
88 | - while (comparaison (m,x,1) == 0 ){ | |
98 | + while (comparaison (m,x,conjug) == 0 ){ | |
89 | 99 | if (tmp1->liste[num(c)]==NULL){return 1;} |
90 | 100 | tmp1=(tmp1->liste[num(c)]); |
91 | 101 | x++; |
... | ... | @@ -95,15 +105,30 @@ int reconaissance(struct cell * d,char * m){ |
95 | 105 | return 1; |
96 | 106 | } |
97 | 107 | |
98 | -int lecture(FILE *fd, struct cell *d){ | |
108 | +int lecture(FILE *fd, struct cell *d , int conjug,int fichier){ | |
99 | 109 | char s[20]; |
100 | 110 | int cmpt=0; |
101 | 111 | int x; |
112 | +FILE *ff; | |
113 | +if(fichier==1){ | |
114 | + ff=fopen("textecorrige.txt","w"); | |
115 | +} | |
102 | 116 | while (fscanf(fd,"%s",s)==1){ |
103 | - x=reconaissance(d,s); | |
117 | + x=reconaissance(d,s,conjug); | |
104 | 118 | cmpt+=x; |
119 | + if(fichier==1){ | |
120 | + if(x==1){ | |
121 | + fprintf(ff,"!- %s -! ",s); | |
122 | + } | |
123 | + else{ | |
124 | + fprintf(ff,"%s ",s); | |
125 | + } | |
126 | + } | |
105 | 127 | if(x==1){printf("%s \n",s);} |
106 | 128 | } |
129 | +if (fichier==1){ | |
130 | + fclose(ff); | |
131 | + } | |
107 | 132 | return cmpt; |
108 | 133 | } |
109 | 134 | |
... | ... | @@ -143,174 +168,20 @@ int main(int argc, char *argv[]) |
143 | 168 | fprintf(stderr, "no such file, or unreachable: %s\n", argv[2]); |
144 | 169 | return EXIT_FAILURE; |
145 | 170 | } |
146 | - | |
147 | - | |
148 | 171 | struct cell *d; |
149 | 172 | d=malloc(sizeof(struct cell)); |
150 | 173 | creation_dico(fp,&d); |
151 | 174 | int inc; |
152 | - inc=lecture(fd,d); | |
153 | - printf("%d mots non reconnus \n", inc); | |
175 | + int conjug; | |
176 | + int fichier; | |
177 | + printf("Voulez vous prendre en compte la conjuguaison ? (fonction encore au stade expérimental) \n oui 1 , non 0 \n"); | |
178 | + scanf("%d",&conjug); | |
179 | + printf("Voulez vous crée un fichier txt contenant votre texte mais avec les mots non reconnue surligné ?\n oui 1 , non 0 \n"); | |
180 | + scanf("%d",&fichier); | |
181 | + inc=lecture(fd,d,conjug,fichier); | |
182 | + printf(" %d mots non reconnus \n ", inc); | |
154 | 183 | suprime_dico(&d); |
155 | - free(fd); | |
156 | - free(fp); | |
157 | - return 1; | |
184 | + fclose(fd); | |
185 | + fclose(fp); | |
186 | + return 0; | |
158 | 187 | } |
159 | -||||||| merged common ancestors | |
160 | -======= | |
161 | -#include <stdio.h> | |
162 | -#include <string.h> | |
163 | -#include <stdlib.h> | |
164 | -#include <stdbool.h> | |
165 | - | |
166 | -struct cell { | |
167 | - int stop; | |
168 | - struct cell * liste[26]; | |
169 | -}; | |
170 | - | |
171 | -int num(char c){ | |
172 | - int x; | |
173 | - x=c; | |
174 | - if (x>96 && x<123){ | |
175 | - x=x-97; | |
176 | - return x; | |
177 | - } | |
178 | - if (x>64 && x<91) { | |
179 | - x=x-65; | |
180 | - return x; | |
181 | - } | |
182 | - printf("erreur num \n"); | |
183 | - return -1; | |
184 | -} | |
185 | - | |
186 | -int ajout_mot(struct cell ** d,char * m){ | |
187 | - char c; | |
188 | - struct cell **tmp1 , *tmp2 ; | |
189 | - int x=0; | |
190 | - if (*d==NULL){return EXIT_FAILURE;} | |
191 | - tmp1=d; | |
192 | - c=m[x]; | |
193 | - while (c != '\0'){ | |
194 | - //printf("%c",c); | |
195 | - if ((*tmp1)->liste[num(c)]==NULL){ | |
196 | - tmp2=malloc(sizeof(struct cell)); | |
197 | - (*tmp1)->liste[num(c)]=tmp2; | |
198 | - } | |
199 | - tmp1=&((*tmp1)->liste[num(c)]); | |
200 | - x++; | |
201 | - c=m[x]; | |
202 | - } | |
203 | - (*tmp1)->stop=1; | |
204 | - //printf("\n"); | |
205 | - return 1; | |
206 | -} | |
207 | - | |
208 | -void creation_dico(FILE *fd, struct cell **d){ | |
209 | - char s[20]; | |
210 | - while (fscanf(fd,"%s",s)==1){ | |
211 | - ajout_mot(d,s); | |
212 | - } | |
213 | -} | |
214 | - | |
215 | -int fin_mot(char c){ | |
216 | - if (c == '\0' || c == ' ' || c== '.' || c == ':' || c == ',' || c == '?' || c == ';' || c == '\'' || c == '\"' || c == '!' || c == '`' || c == '-' || c == '_'){ | |
217 | - return 1;} | |
218 | - return 0; | |
219 | -} | |
220 | - | |
221 | -int comparaison(char *m , int x , int conjug){ | |
222 | - if (fin_mot(m[x])==1){ | |
223 | - return 1; | |
224 | - } | |
225 | - if (conjug==1){ | |
226 | - if (fin_mot(m[x+1])==1 && m[x]=='s'){ | |
227 | - return 1; | |
228 | - } | |
229 | - if (fin_mot(m[x+2])==1 && m[x+1]=='d' && m[x]=='e'){ | |
230 | - return 1; | |
231 | - } | |
232 | - if (fin_mot(m[x+3])==1 && m[x+2]=='g' && m[x+1]=='n' && m[x]=='i'){ | |
233 | - return 1; | |
234 | - } | |
235 | - } | |
236 | - return 0; | |
237 | -} | |
238 | - | |
239 | -int reconaissance(struct cell * d,char * m){ | |
240 | - char c; | |
241 | - struct cell *tmp1; | |
242 | - int x=0; | |
243 | - tmp1=d; | |
244 | - if (d==NULL){return 1;} | |
245 | - c=m[x]; | |
246 | - while (comparaison (m,x,1) == 0 ){ | |
247 | - if (tmp1->liste[num(c)]==NULL){return 1;} | |
248 | - tmp1=(tmp1->liste[num(c)]); | |
249 | - x++; | |
250 | - c=m[x]; | |
251 | - } | |
252 | - if (tmp1->stop==1) {return 0;} | |
253 | - return 1; | |
254 | -} | |
255 | - | |
256 | -int lecture(FILE *fd, struct cell *d){ | |
257 | - char s[20]; | |
258 | - int cmpt=0; | |
259 | - int x; | |
260 | - while (fscanf(fd,"%s",s)==1){ | |
261 | - x=reconaissance(d,s); | |
262 | - cmpt+=x; | |
263 | - if(x==1){printf("%s \n",s);} | |
264 | - } | |
265 | - return cmpt; | |
266 | -} | |
267 | - | |
268 | -void suprime_dico(struct cell **d){ | |
269 | - int i=0; | |
270 | - for (i=0;i<26;i++){ | |
271 | - if ((*d)->liste[i]!=NULL){ | |
272 | - suprime_dico(&((*d)->liste[i])); | |
273 | - } | |
274 | - } | |
275 | - free(*d); | |
276 | -} | |
277 | - | |
278 | - | |
279 | -int main(int argc, char *argv[]) | |
280 | -{ | |
281 | - if (argc < 3) | |
282 | - { | |
283 | - fprintf(stderr, "usage: hash <file_name>\n"); | |
284 | - return EXIT_FAILURE; | |
285 | - } | |
286 | - | |
287 | - FILE *fp; | |
288 | - printf("%s\n",argv[1]); | |
289 | - fp=fopen(argv[1], "r"); | |
290 | - if (fp==NULL) | |
291 | - { | |
292 | - fprintf(stderr, "no such file, or unreachable: %s\n", argv[1]); | |
293 | - return EXIT_FAILURE; | |
294 | - } | |
295 | - | |
296 | - FILE *fd; | |
297 | - printf("%s\n",argv[2]); | |
298 | - fd=fopen(argv[2], "r"); | |
299 | - if (fd==NULL) | |
300 | - { | |
301 | - fprintf(stderr, "no such file, or unreachable: %s\n", argv[2]); | |
302 | - return EXIT_FAILURE; | |
303 | - } | |
304 | - | |
305 | - | |
306 | - struct cell *d; | |
307 | - d=malloc(sizeof(struct cell)); | |
308 | - creation_dico(fp,&d); | |
309 | - int inc; | |
310 | - inc=lecture(fd,d); | |
311 | - printf("%d mots non reconnus \n", inc); | |
312 | - suprime_dico(&d); | |
313 | - free(fd); | |
314 | - free(fp); | |
315 | -} | |
316 | ->>>>>>> 8af1f2429503e7afb5adcccb10b4548b1dc0e101 | ... | ... |
projetV2.out
No preview for this file type
1 | 1 | Out of the night that covers me, |
2 | - Black as the pit from pole to pole, | |
2 | +Black as the Pit from pole to pole, | |
3 | 3 | I thank whatever gods may be |
4 | - For my unconquerable soul. | |
4 | +For my unconquerable soul. | |
5 | 5 | |
6 | 6 | In the fell clutch of circumstance |
7 | - I have not winced nor cried aloud. | |
7 | +I have not winced nor cried aloud. | |
8 | 8 | Under the bludgeonings of chance |
9 | - My head is bloody, but unbowed. | |
9 | +My head is bloody, but unbowed. | |
10 | 10 | |
11 | 11 | Beyond this place of wrath and tears |
12 | - Looms but the Horror of the shade, | |
12 | +Looms but the Horror of the shade, | |
13 | 13 | And yet the menace of the years |
14 | - Finds and shall find me unafraid. | |
14 | +Finds, and shall find, me unafraid. | |
15 | 15 | |
16 | 16 | It matters not how strait the gate, |
17 | - How charged with punishments the scroll, | |
18 | -I am the master of my fate, | |
19 | - I am the captain of my soul. | |
20 | 17 | \ No newline at end of file |
18 | +How charged with punishments the scroll. | |
19 | +I am the master of my fate: | |
20 | +I am the captain of my soul. | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +Out of the night that covers me, Black !- as -! the Pit from pole to pole, !- I -! thank whatever gods may be For my !- unconquerable -! soul. In the fell clutch of circumstance !- I -! have not !- winced -! nor !- cried -! aloud. Under the !- bludgeonings -! of chance My head !- is -! bloody, but !- unbowed. -! Beyond !- this -! place of wrath and tears Looms but the Horror of the shade, And yet the menace of the years Finds, and shall find, me !- unafraid. -! It matters not how strait the gate, How !- charged -! with punishments the scroll. !- I -! am the master of my fate: !- I -! am the captain of my soul. | |
0 | 2 | \ No newline at end of file | ... | ... |