diff --git a/doc.txt b/doc.txt index aed6915..0a453f7 100644 --- a/doc.txt +++ b/doc.txt @@ -1 +1 @@ -aspirateur chien. chienne, banane. \ No newline at end of file +spirateur, chevre, chien, chat;. chienne;? banc. diff --git a/tree.c b/tree.c index 7b68dd3..951d93d 100644 --- a/tree.c +++ b/tree.c @@ -63,7 +63,8 @@ void add_in_tree(Node Tree, char word[]) new->next[i]=NULL; } Tree2->next[letter-'a'] = new; - Tree2->endWord = false; + if(!(Tree2->endWord)) + Tree2->endWord = false; Tree2=Tree2->next[letter-'a']; printf("%c %d\t", letter, letter-'a'); printf("okB %d\n", j); @@ -77,12 +78,8 @@ void add_in_tree(Node Tree, char word[]) bool is_end_caract(char letter) { - int endCaract[nb_car] = {0, 44, 45, 46, 47}; // a remplir - for(int i=0; i=32 && letter<=47)||(letter>=58 && letter<=64)||(letter>=123 && letter<=126)||(letter==128)) return true; return false; } @@ -94,26 +91,39 @@ char max_index(char word[]) return index; } -void scan_word(Node Tree, char word[], int* error) // ne gère pas les mots avec endWord = true +void scan_word(Node Tree, char word[], int* error) // si un mot démarre juste après un caractère de fin, la fonction ne lit pas les mots séparément { + bool endWord; + bool stop = false; int ind = 0; char letter; Node Tree2 = Tree; while(!is_end_caract(word[ind])) { + stop = false; letter = word[ind]; if(Tree2->next[letter-'a']!=NULL) { ind++; Tree2 = Tree2->next[letter-'a']; + endWord = Tree2->endWord; + if(endWord) printf("end :: %s ::\n", word); } else { printf("mot : %s erreur :%c %d \n", word, word[ind], word[ind]); (*error)++; + printf("%d\n", ind); ind = max_index(word); + printf("%d\n", ind); + stop = true; } } + if(!endWord && !stop) + { + (*error)++; + printf("---%s---\n", word); + } } void read_txt(FILE* fp, Node* Tree, int* error) @@ -180,10 +190,11 @@ void print_first(Node Tree) { Node cpTree = Tree; int index = 0; - while(!is_leaf(cpTree)) + while(!is_leaf(cpTree) || !(cpTree->endWord)) { index = find_index(cpTree); printf("%c\n", (cpTree->next[index])->letter); + if(cpTree->next[index]->endWord) printf("fin\n"); cpTree=cpTree->next[index]; } } @@ -201,18 +212,13 @@ int main(int argc, char *argv[]) read_lib(fp_lib, &tree); read_txt(fp_txt, &tree, &error); - printf("%p\n", tree); + // printf("%p\n", tree); print_first(tree); - printf("\n"); - print_tree(tree, 0); + //printf("\n"); + //print_tree(tree, 0); printf("erreurs : %d\n", error); - int endCaract[nb_car] = {0, 44, 45, 46, 47}; // a remplir - for(int i=0; i