From 003d3e48f2e0955c6a4373de1d5dd7d2c982aa6f Mon Sep 17 00:00:00 2001 From: Baptiste JL Date: Wed, 24 Apr 2019 23:42:18 +0200 Subject: [PATCH] update6 withHash --- dico.c | 62 +++++++++++++++++++++++++++++++++++++++++--------------------- dico.h | 4 ++-- treeh.c | 11 ++++++----- treeh.h | 11 +++++++++-- 4 files changed, 58 insertions(+), 30 deletions(-) diff --git a/dico.c b/dico.c index 4184c2a..1d3569e 100644 --- a/dico.c +++ b/dico.c @@ -1,7 +1,7 @@ #include "dico.h" void make_empty_dico(dico d){ - for(int i=0;inext[i],stream); + } } diff --git a/dico.h b/dico.h index 1d12267..5314ce4 100644 --- a/dico.h +++ b/dico.h @@ -7,7 +7,7 @@ typedef tree dico[NBCHAR]; void make_empty_dico(dico); void delete_dico(dico); -bool addto_dico(dico,string); +bool addto_dico(dico,const string); void loadfrom_file(dico,FILE*); @@ -15,6 +15,6 @@ void loadfrom_keyboard(dico);//i.e. loadfrom_file(dico,stdin); void printto_file(dico,FILE*); void printto_terminal(dico);//i.e. printto_file(dico,stdout); - +void print(tree,FILE*,string) #endif diff --git a/treeh.c b/treeh.c index c86dafc..33bf024 100644 --- a/treeh.c +++ b/treeh.c @@ -45,12 +45,13 @@ bool is_followed(const tree t){ } //functions is_end -bool is_end(const tree t){return t->isEnd & 21;}//0b00010101 -bool ends_with_apostrophe(const tree t){return t->isEnd & 42;}//0b00101010 +bool is_end(const tree t){return isEnd;} +bool is_straight_end(const tree t){return t->isEnd & STRAIGHT_END;} +bool ends_with_apostrophe(const tree t){return t->isEnd & APOSTROPHE_END;} -bool is_common_end(const tree t){return t->isEnd & 3;}//0b00000011 -bool is_proper_end(const tree t){return t->isEnd & 12;}//0b00001100 -bool is_acronyme_end(const tree t){return t->isEnd & 48;}//0b00110000 +bool is_common_end(const tree t){return t->isEnd & COMMON_END ;} +bool is_proper_end(const tree t){return t->isEnd & PROPER_END;} +bool is_acronyme_end(const tree t){return t->isEnd & ACRONYME_END;} diff --git a/treeh.h b/treeh.h index 0bc7604..bf53c35 100644 --- a/treeh.h +++ b/treeh.h @@ -8,6 +8,12 @@ #define NBCHAR 26 //A-Z +#define COMMON_END 0x03 +#define PROPER_END 0x0B +#define ACRONYME_END 0x30 +#define STRAIGHT_END 0X15 +#define APOSTROPHE_END 0X2A + typedef char *string,byte; typedef struct _node node, *tree; struct _node{ @@ -26,8 +32,9 @@ void delete_tree(tree);//free(tree) and delete tree on all t->next bool is_empty(const tree);//==NULL bool is_followed(const tree);//if true tree has following letters -bool is_end(const tree);//if true word can end here -bool ends_with_apostrophe(const tree);//if true word can be word's +bool is_end(const tree);//true when at least 1 of the following functions is true +bool is_straight_end(const tree);//if true word can end here +bool ends_with_apostrophe(const tree);//if true word can end here with apostrophe bool is_common_end(const tree);//if true all letters are lower bool is_proper_end(const tree);//if true 1st letter is upper bool is_acronyme_end(const tree);//if true all letters are upper -- libgit2 0.21.2