diff --git a/doc.txt b/doc.txt index c064ff3..e77e542 100644 --- a/doc.txt +++ b/doc.txt @@ -1,4 +1,4 @@ aspirateur. Doucement, bien; -chien +hien chien. Doucament. -chien +chie diff --git a/main b/main index 51ea0ce..6c92ff4 100755 Binary files a/main and b/main differ diff --git a/main.c~ b/main.c~ new file mode 100644 index 0000000..de35356 --- /dev/null +++ b/main.c~ @@ -0,0 +1,34 @@ +// -------------------------------------------------------- +// Projet IMA3 2019 - Lecture d'une bibliothèque +// Décompte du nombre de fautes d'orthographe dans un texte +// Normand Quentin & Rouillé Guillaume +// -------------------------------------------------------- + +#include "tree.h" + +int main(int argc, char *argv[]) +{ + Node tree = NULL; + int error = 0; + FILE* fp_lib; + FILE* fp_txt; + fp_lib = fopen(argv[argc-2], "r"); + fp_txt = fopen(argv[argc-1], "r"); + + init_tree(&tree); + read_lib(fp_lib, &tree); + read_txt(fp_txt, &tree, &error); + + // printf("%p\n", tree); + + //print_first(tree); + //printf("\n"); + //print_tree(tree, 0); + + printf("erreurs : %d\n", error); + + free_tree(&tree); + free(fp_lib); + free(fp_txt); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..ade4c89 --- /dev/null +++ b/test.txt @@ -0,0 +1,8 @@ +In the old days, ants and cicadas were friends. They were very different. The ants were hardwood, but the cicadas were lazy. +In the summer, the ant families were very busy. They knew that in the winter they would have to stay in their anthill. They wanted to have enough food for the whole winter. +While the ants worked hard, the cicadas didn't do anything. They sang and danced all day. When they were hungry, they could fly to the farm and get something to eat. +One day the cicadas were singing and dancing. They saw a long line of ants bringing food to their anthill. The cicadas said, Stop, my silly friends. It's a very nice day. Come and dance with us. The ants said, Don't you know about winter? If you don't work now, you'll have trouble later. +But the cicadas said, We have strong wings. We can fly anywhere we want. Stupid ants! And they continued to sing and dance. +In the winter, it rained or snowed all the time, and it was very cold. In the anthill, there was singing and dancing. But the cicadas had nothing to eat. They asked the ants for some food. The ants said, We thought you could fly anywhere. Now who is stupid and silly? +The cicadas cried and said that their wings were wet from the rain. The ants said, We're sorry, but now it's to late. If we help you, there won't be enough food for us. Sorry, very sorry. And the ants closed their door. +The next day, when the ants opened their door, all the cicadas were dead! That's why we can hear cicadas sing in the summer, but in the winter they are silent.nt...... \ No newline at end of file diff --git a/texte.txt b/texte.txt index b36daf1..3323557 100644 --- a/texte.txt +++ b/texte.txt @@ -17,3 +17,10 @@ The ant and the cicada The cicadas cried and said that their wings were wet from the rain. The ants said, We're sorry, but now it's to late. If we help you, there won't be enough food for us. Sorry, very sorry. And the ants closed their door. The next day, when the ants opened their door, all the cicadas were dead! That's why we can hear cicadas sing in the summer, but in the winter they are silent. + + + + + + + diff --git a/tree.c~ b/tree.c~ new file mode 100644 index 0000000..0c848cf --- /dev/null +++ b/tree.c~ @@ -0,0 +1,61 @@ +#include +#include +#include + +typedef struct node* Node; + +typedef struct node { + char letter; + Node next[26]; + bool endWord; +}node; + +void mk_empty_tree(Node* Tree) +{ + *Tree = NULL; +} + +bool is_empty_tree(Node* Tree) +{ + return(*Tree==NULL); +} + +void init_tree(Node* Tree) +{ + if(is_empty_tree(Tree)) + { + *Tree = malloc(sizeof(Node)); + Tree->letter = '?'; + Tree->endWord = false; + for(int i=0; i<26; i++) + Tree->next[i] = NULL; + } +} + +void add_in_tree(Node Tree, char word[]) +{ + char letter = word[0]; + while(letter != '/0') + { + if(Tree->next[letter-'a']!=NULL) + Tree = Tree->next[letter-'a']; + else + { + Node new = NULL; + new = malloc(sizeof(Node)); + new->letter = letter; + for(int i=0; i<26; i++) + { + new->next[i]=NULL; + } + Tree->next[letter-'a'] = new; + } + } + +} + + +int main(int argc, char argv[]) +{ + return 0; +} diff --git a/tree.h~ b/tree.h~ new file mode 100644 index 0000000..a70bfbc --- /dev/null +++ b/tree.h~ @@ -0,0 +1,68 @@ +// -------------------------------------------------------- +// Projet IMA3 2019 - Lecture d'une bibliothèque +// Décompte du nombre de fautes d'orthographe dans un texte +// Normand Quentin & Rouillé Guillaume +// -------------------------------------------------------- + +// Initialisation des variables et inclusion des bibliothèques +#include +#include +#include +#define MAX 30 // taille maximale d'une chaîne lue dans un fichier +#define NB_CARAC 27 // nombre de caractères différents pouvant être identifiés -> 89 avec accentués + +// Déclaration de la structure 'trie' ou 'arbre indexé', ainsi que des pointeurs associés +typedef struct node* Node; + +typedef struct node { + char letter; + Node next[NB_CARAC]; + bool endWord; +}node; + +// Fonction permettant de savoir si la structure est vide +bool is_empty_tree(Node Tree); + +// Fonction permettant de savoir si le tableau 'next' est un tableau de pointeurs NULL +bool is_leaf(Node Tree); + +// Initialisation de la structure accueillant le dictionnaire +void init_tree(Node* Tree); + +// Détermine l'indice de rangement dans le tableau 'next' du caractère 'letter' +int find_caract_indice(char letter); // Ne fonctionne pas pour les caractères accentués + + +// Fonction d'ajout d'un mot 'word' dans la structure 'tree' de type 'arbre indexé' +void add_in_tree(Node Tree, char word[]); + +// Fonction qui détermine si le caractère est un caractère de fin de mot (espace, ',', ';', '.', etc..) +bool is_end_caract(char letter); + +// Renvoi l'indice maximum du mot 'word' +char max_index(char word[]); + +// Détermine si le mot 'word' est présent dans l'arbre indexé +void scan_word(Node Tree, char word[], int* error); + +// Retourne 'true' si le mot 'word' est non accentué, 'false' sinon +bool no_accent(char word[]); + +// Transmet les mots du texte à analyser à 'scan_word' +void read_txt(FILE* fp, Node* Tree, int* error); + +// Transmet les mots de la biliothèque à 'add_in_tree' +void read_lib(FILE* fp, Node* Tree); + +// A SUPPRIMER +void print_tree(Node Tree, int index); + +// A SUPPRIMER +int find_index(Node tree); + +// A SUPPRIMER +void print_first(Node Tree); + +// Libère l'espace mémoire associé à l'arbre indexé +void free_tree(Node* Tree); + -- libgit2 0.21.2