From 1ca5667ac671007e43dfb9da93b912a4dc7c199c Mon Sep 17 00:00:00 2001 From: mduquesn Date: Tue, 30 Apr 2019 10:20:35 +0200 Subject: [PATCH] Rapport --- PROJET.docx | Bin 0 -> 45575 bytes PROJET.odt | Bin 11403 -> 0 bytes PROJET.pdf | Bin 189018 -> 0 bytes README.md | 1 + projetV2.c | 213 ++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- projetV2.out | Bin 17216 -> 0 bytes texte | 18 +++++++++--------- textecorrige.txt | 1 + 8 files changed, 53 insertions(+), 180 deletions(-) create mode 100644 PROJET.docx create mode 100644 textecorrige.txt diff --git a/PROJET.docx b/PROJET.docx new file mode 100644 index 0000000..9690041 Binary files /dev/null and b/PROJET.docx differ diff --git a/PROJET.odt b/PROJET.odt index a2379a3..50c6891 100644 Binary files a/PROJET.odt and b/PROJET.odt differ diff --git a/PROJET.pdf b/PROJET.pdf index 62ca5d3..0f564ba 100644 Binary files a/PROJET.pdf and b/PROJET.pdf differ diff --git a/README.md b/README.md index f210605..9bb296b 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,5 @@ exemple : Nom des 2 arguments donnés mots non reconnus nombre total de mots non reconnus +si autorisation de création d'un fichier texte , alors creation dans le répertoire de lecture de textecorrige.txt diff --git a/projetV2.c b/projetV2.c index 28fb4ee..413b12c 100644 --- a/projetV2.c +++ b/projetV2.c @@ -1,4 +1,3 @@ -<<<<<<< HEAD #include #include #include @@ -24,6 +23,17 @@ int num(char c){ return -1; } +struct cell * creation_cell (){ + struct cell * tmp ; + int i=0; + tmp=malloc(sizeof(struct cell)); + tmp->stop=0; + for (i=0;i<26;i++){ + tmp->liste[i]=NULL; + } + return tmp; +} + int ajout_mot(struct cell ** d,char * m){ char c; struct cell **tmp1 , *tmp2 ; @@ -34,7 +44,7 @@ int ajout_mot(struct cell ** d,char * m){ while (c != '\0'){ //printf("%c",c); if ((*tmp1)->liste[num(c)]==NULL){ - tmp2=malloc(sizeof(struct cell)); + tmp2=creation_cell(); (*tmp1)->liste[num(c)]=tmp2; } tmp1=&((*tmp1)->liste[num(c)]); @@ -78,14 +88,14 @@ int comparaison(char *m , int x , int conjug){ return 0; } -int reconaissance(struct cell * d,char * m){ +int reconaissance(struct cell * d,char * m , int conjug){ char c; struct cell *tmp1; int x=0; tmp1=d; if (d==NULL){return 1;} c=m[x]; - while (comparaison (m,x,1) == 0 ){ + while (comparaison (m,x,conjug) == 0 ){ if (tmp1->liste[num(c)]==NULL){return 1;} tmp1=(tmp1->liste[num(c)]); x++; @@ -95,15 +105,30 @@ int reconaissance(struct cell * d,char * m){ return 1; } -int lecture(FILE *fd, struct cell *d){ +int lecture(FILE *fd, struct cell *d , int conjug,int fichier){ char s[20]; int cmpt=0; int x; +FILE *ff; +if(fichier==1){ + ff=fopen("textecorrige.txt","w"); +} while (fscanf(fd,"%s",s)==1){ - x=reconaissance(d,s); + x=reconaissance(d,s,conjug); cmpt+=x; + if(fichier==1){ + if(x==1){ + fprintf(ff,"!- %s -! ",s); + } + else{ + fprintf(ff,"%s ",s); + } + } if(x==1){printf("%s \n",s);} } +if (fichier==1){ + fclose(ff); + } return cmpt; } @@ -143,174 +168,20 @@ int main(int argc, char *argv[]) fprintf(stderr, "no such file, or unreachable: %s\n", argv[2]); return EXIT_FAILURE; } - - struct cell *d; d=malloc(sizeof(struct cell)); creation_dico(fp,&d); int inc; - inc=lecture(fd,d); - printf("%d mots non reconnus \n", inc); + int conjug; + int fichier; + printf("Voulez vous prendre en compte la conjuguaison ? (fonction encore au stade expérimental) \n oui 1 , non 0 \n"); + scanf("%d",&conjug); + printf("Voulez vous crée un fichier txt contenant votre texte mais avec les mots non reconnue surligné ?\n oui 1 , non 0 \n"); + scanf("%d",&fichier); + inc=lecture(fd,d,conjug,fichier); + printf(" %d mots non reconnus \n ", inc); suprime_dico(&d); - free(fd); - free(fp); - return 1; + fclose(fd); + fclose(fp); + return 0; } -||||||| merged common ancestors -======= -#include -#include -#include -#include - -struct cell { - int stop; - struct cell * liste[26]; -}; - -int num(char c){ - int x; - x=c; - if (x>96 && x<123){ - x=x-97; - return x; - } - if (x>64 && x<91) { - x=x-65; - return x; - } - printf("erreur num \n"); - return -1; -} - -int ajout_mot(struct cell ** d,char * m){ - char c; - struct cell **tmp1 , *tmp2 ; - int x=0; - if (*d==NULL){return EXIT_FAILURE;} - tmp1=d; - c=m[x]; - while (c != '\0'){ - //printf("%c",c); - if ((*tmp1)->liste[num(c)]==NULL){ - tmp2=malloc(sizeof(struct cell)); - (*tmp1)->liste[num(c)]=tmp2; - } - tmp1=&((*tmp1)->liste[num(c)]); - x++; - c=m[x]; - } - (*tmp1)->stop=1; - //printf("\n"); - return 1; -} - -void creation_dico(FILE *fd, struct cell **d){ - char s[20]; - while (fscanf(fd,"%s",s)==1){ - ajout_mot(d,s); - } -} - -int fin_mot(char c){ - if (c == '\0' || c == ' ' || c== '.' || c == ':' || c == ',' || c == '?' || c == ';' || c == '\'' || c == '\"' || c == '!' || c == '`' || c == '-' || c == '_'){ - return 1;} - return 0; -} - -int comparaison(char *m , int x , int conjug){ - if (fin_mot(m[x])==1){ - return 1; - } - if (conjug==1){ - if (fin_mot(m[x+1])==1 && m[x]=='s'){ - return 1; - } - if (fin_mot(m[x+2])==1 && m[x+1]=='d' && m[x]=='e'){ - return 1; - } - if (fin_mot(m[x+3])==1 && m[x+2]=='g' && m[x+1]=='n' && m[x]=='i'){ - return 1; - } - } - return 0; -} - -int reconaissance(struct cell * d,char * m){ - char c; - struct cell *tmp1; - int x=0; - tmp1=d; - if (d==NULL){return 1;} - c=m[x]; - while (comparaison (m,x,1) == 0 ){ - if (tmp1->liste[num(c)]==NULL){return 1;} - tmp1=(tmp1->liste[num(c)]); - x++; - c=m[x]; - } - if (tmp1->stop==1) {return 0;} - return 1; -} - -int lecture(FILE *fd, struct cell *d){ - char s[20]; - int cmpt=0; - int x; - while (fscanf(fd,"%s",s)==1){ - x=reconaissance(d,s); - cmpt+=x; - if(x==1){printf("%s \n",s);} - } - return cmpt; -} - -void suprime_dico(struct cell **d){ - int i=0; - for (i=0;i<26;i++){ - if ((*d)->liste[i]!=NULL){ - suprime_dico(&((*d)->liste[i])); - } - } - free(*d); -} - - -int main(int argc, char *argv[]) -{ - if (argc < 3) - { - fprintf(stderr, "usage: hash \n"); - return EXIT_FAILURE; - } - - FILE *fp; - printf("%s\n",argv[1]); - fp=fopen(argv[1], "r"); - if (fp==NULL) - { - fprintf(stderr, "no such file, or unreachable: %s\n", argv[1]); - return EXIT_FAILURE; - } - - FILE *fd; - printf("%s\n",argv[2]); - fd=fopen(argv[2], "r"); - if (fd==NULL) - { - fprintf(stderr, "no such file, or unreachable: %s\n", argv[2]); - return EXIT_FAILURE; - } - - - struct cell *d; - d=malloc(sizeof(struct cell)); - creation_dico(fp,&d); - int inc; - inc=lecture(fd,d); - printf("%d mots non reconnus \n", inc); - suprime_dico(&d); - free(fd); - free(fp); -} ->>>>>>> 8af1f2429503e7afb5adcccb10b4548b1dc0e101 diff --git a/projetV2.out b/projetV2.out index 7f1f101..b31b847 100644 Binary files a/projetV2.out and b/projetV2.out differ diff --git a/texte b/texte index 27b5023..11c1e6a 100644 --- a/texte +++ b/texte @@ -1,19 +1,19 @@ Out of the night that covers me, - Black as the pit from pole to pole, +Black as the Pit from pole to pole, I thank whatever gods may be - For my unconquerable soul. +For my unconquerable soul. In the fell clutch of circumstance - I have not winced nor cried aloud. +I have not winced nor cried aloud. Under the bludgeonings of chance - My head is bloody, but unbowed. +My head is bloody, but unbowed. Beyond this place of wrath and tears - Looms but the Horror of the shade, +Looms but the Horror of the shade, And yet the menace of the years - Finds and shall find me unafraid. +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. \ No newline at end of file +How charged with punishments the scroll. +I am the master of my fate: +I am the captain of my soul. diff --git a/textecorrige.txt b/textecorrige.txt new file mode 100644 index 0000000..e08261c --- /dev/null +++ b/textecorrige.txt @@ -0,0 +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. \ No newline at end of file -- libgit2 0.21.2