From ee3fc0eb8797af2b30ab48842a5600b7a97e13b3 Mon Sep 17 00:00:00 2001 From: tvieuble Date: Tue, 30 Apr 2019 18:14:15 +0200 Subject: [PATCH] Ajout caractères spéciaux --- dicoesp.txt | 3 +++ projetfinalaccent2.c | 57 +++++++++++++++++++++++++++------------------------------ projetfinalaccent2.exe | Bin 0 -> 138805 bytes texte.txt | 13 +++++-------- words.txt | 2 +- 5 files changed, 36 insertions(+), 39 deletions(-) create mode 100644 dicoesp.txt create mode 100644 projetfinalaccent2.exe diff --git a/dicoesp.txt b/dicoesp.txt new file mode 100644 index 0000000..f66900d --- /dev/null +++ b/dicoesp.txt @@ -0,0 +1,3 @@ +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 +niño +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 \ No newline at end of file diff --git a/projetfinalaccent2.c b/projetfinalaccent2.c index 38f00fd..3f3c392 100644 --- a/projetfinalaccent2.c +++ b/projetfinalaccent2.c @@ -3,7 +3,7 @@ #include #include -#define A 256 +#define A 259 struct node { wchar_t lettre; @@ -15,20 +15,19 @@ struct cell { struct cell* arbreSuivant; }; -void lien_listeFils(struct cell** pL) { - struct cell* p; - p = malloc(sizeof(struct cell)); - - (*pL)->arbre->listeFils = p; -} - void initialisation_tab_arbre(struct node tab[]) { int i = 0; - for(wchar_t u = 'a'; u < A; u++) { + for(wchar_t u = 'a'; u < A-3; u++) { tab[i].lettre = u; //ajout lettres minuscules tab[i].listeFils = NULL; i++; } + tab[A-3].lettre = '?'; + tab[A-2].lettre = '!'; + tab[A-1].lettre = '\''; + tab[A-3].listeFils = NULL; + tab[A-2].listeFils = NULL; + tab[A-1].listeFils = NULL; } void ajout_tete(wchar_t elem, struct cell** pL) { @@ -82,7 +81,7 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; } - else if(motLu[0] > 'z') { + else if((motLu[0] < 'A') || (motLu[0] > 'z')) { indice = indice_lettre(tab_arbre_prcp, motLu[0]); localisationArbre = &tab_arbre_prcp[indice].listeFils; if(indice == 0) { @@ -98,7 +97,6 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { } while((motLu[i] != '\0') && (estUneLettre == 1)) { i += 1; - //wprintf(L"lettre lue %d\n", motLu[i]); localisationArbre = insertion(motLu[i], localisationArbre); } } @@ -107,7 +105,7 @@ void remplir_dico(FILE* fd, struct node tab_arbre_prcp[]) { wprintf(L"%d mots inseres dans le dictionnaire.\n", cptmot); } -struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) { +struct cell ** test_mot(wchar_t mot, struct cell** localisation, int* verif) { if((*localisation == NULL) || (*localisation)->arbre->lettre > mot) { *verif = 0; @@ -124,7 +122,7 @@ struct cell** test_mot(wchar_t mot, struct cell** localisation, int* verif) { void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { struct cell** localisationArbre = NULL; int verif; - int indice = 0; + int indice = 0, cptfaute = 0; wchar_t motLu[50]; while(fwscanf(fd, L"%ls", motLu)==1) { verif = 1; @@ -135,11 +133,12 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; } - else if(motLu[0] > 'z') { + else if((motLu[0] < 'A') || (motLu[0] > 'z')) { + printf("jsuisla\n"); indice = indice_lettre(tab_arbre_prcp, motLu[0]); localisationArbre = &tab_arbre_prcp[indice].listeFils; if(indice == 0) { - wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n"); + wprintf(L"Erreur correction txt : L'un des caracteres n'est pas une lettre\n"); verif = 0; } } @@ -149,10 +148,15 @@ void correction_txt(FILE* fd, struct node tab_arbre_prcp[]) { } while((verif == 1) && (motLu[i] != '\0')) { i += 1; + if((motLu[i] == '.') || (motLu[i] == ',') || (motLu[i] == ';') || (motLu[i] == ':') || (motLu[i] == '!') || (motLu[i] == '?')) motLu[i] = '\0'; //prendre en compte les fins de phrase localisationArbre = test_mot(motLu[i], localisationArbre, &verif); } - if(verif == 0) wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu); + if(verif == 0) { + wprintf(L"Mot %ls non present dans le dicitonnaire.\n", motLu); + cptfaute += 1; + } } + printf("Le texte comporte %d faute(s)\n", cptfaute); fclose(fd); } @@ -172,7 +176,7 @@ void correction_mot(struct node tab_arbre_prcp[]) { else if((motLu[0] >= 'a') && (motLu[0] <= 'z')) { localisationArbre = &tab_arbre_prcp[motLu[0]-97].listeFils; } - else if(motLu[0] > 'z') { + else if((motLu[0] < 'A') || (motLu[0] > 'z')) { indice = indice_lettre(tab_arbre_prcp, motLu[0]); localisationArbre = &tab_arbre_prcp[indice].listeFils; if(indice == 0) { @@ -186,28 +190,23 @@ void correction_mot(struct node tab_arbre_prcp[]) { } while((verif == 1) && (motLu[i] != '\0')) { i += 1; + if((motLu[i] == '.') || (motLu[i] == ',') || (motLu[i] == ';') || (motLu[i] == ':') || (motLu[i] == '!') || (motLu[i] == '?')) motLu[i] = '\0'; wprintf(L"lettre lue %d\n", motLu[i]); localisationArbre = test_mot(motLu[i], localisationArbre, &verif); } - if(verif == 0) wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu); + if(verif == 0) { + wprintf(L"Mot : %ls non present dans le dicitonnaire.\n", motLu); + } else wprintf(L"Mot : %ls correct\n", motLu); } } -/*void supp_tete(struct cell** pL) { - struct cell* p; - p = *pL; - *pL = (*pL) -> arbreSuivant; - free(p); -}*/ - void desalocationArbre(struct cell** pL) { if ((*pL) == NULL) return; desalocationArbre(&(*pL)-> arbreSuivant); desalocationArbre(&(*pL)-> arbre -> listeFils); - free((*pL) -> arbre); free(*pL); } @@ -215,9 +214,7 @@ void desalocationArbre(struct cell** pL) { void desalocationTableauArbre(struct node tab_arbre[]){ int i = 0; for(wchar_t u = 'a'; u < A; u++) { - - desalocationArbre(&tab_arbre[i].listeFils); - + desalocationArbre(&tab_arbre[i].listeFils); i++; } } @@ -229,7 +226,6 @@ int main(int argc, char* argv[]) { FILE* dico = NULL; FILE* txt = NULL; struct node tab_arbre[A]; - //struct node * a; if(argc>2) { dico = fopen(argv[1], "r"); @@ -245,6 +241,7 @@ int main(int argc, char* argv[]) { } initialisation_tab_arbre(tab_arbre); remplir_dico(dico, tab_arbre); //on suppose qu'il n'y a pas d'accents dans le dictionnaire + for(int i = 0; i < A; i++) wprintf(L"%lc\n", tab_arbre[i].lettre); correction_txt(txt, tab_arbre); correction_mot(tab_arbre); desalocationTableauArbre(tab_arbre); diff --git a/projetfinalaccent2.exe b/projetfinalaccent2.exe new file mode 100644 index 0000000..aae6b87 Binary files /dev/null and b/projetfinalaccent2.exe differ diff --git a/texte.txt b/texte.txt index dcc2fad..6456aa8 100644 --- a/texte.txt +++ b/texte.txt @@ -1,8 +1,5 @@ -paul -arbre Tanguy -feuilles -vapeur -abricots -abricot -agen -feuil +He mustn't drink. +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. +They said to the barman, two whiskies, please. +The barman said, what about your frend ? Doesn't he wants an whisky? +Oh, no, they said,he mustn't drink. He's diving. \ No newline at end of file diff --git a/words.txt b/words.txt index 3f9b27f..cd28f5b 100644 --- a/words.txt +++ b/words.txt @@ -1,4 +1,4 @@ -A +A A's AA's AB's -- libgit2 0.21.2