Commit a0fe64d275c2d1bff0803a45a30b12a94ea78a2b
1 parent
17b49163
Update dico
Showing
2 changed files
with
26 additions
and
11 deletions
Show diff stats
@@ -4,16 +4,31 @@ void make_empty_dico(dico d){ | @@ -4,16 +4,31 @@ void make_empty_dico(dico d){ | ||
4 | for(int i=0;i<NB1CHAR;i++) | 4 | for(int i=0;i<NB1CHAR;i++) |
5 | d[i]=NULL; | 5 | d[i]=NULL; |
6 | } | 6 | } |
7 | -void delete_dico(dico_d){ | 7 | +void delete_dico(dico d){ |
8 | for(int i=0;i<NB1CHAR;i++) | 8 | for(int i=0;i<NB1CHAR;i++) |
9 | delete_tree(d[i]); | 9 | delete_tree(d[i]); |
10 | } | 10 | } |
11 | 11 | ||
12 | +byte end_kind(const string s){ | ||
13 | + byte endKind=0; | ||
14 | + int i=1; | ||
15 | + if(!isalpha(s[0])) | ||
16 | + return 0; | ||
17 | + if(islower(s[0])){ | ||
18 | + endKind=1; | ||
19 | + while(islower(s[i])); | ||
20 | + } | ||
21 | + else {//if isupper(s[0]) | ||
22 | + | ||
23 | + } | ||
24 | + endKind*=( (s[i]=='\0') + 2* (s[i]=='\''&&s[i+1]=='s'&&s[i+2]=='\0') ); | ||
25 | + return endKind; | ||
26 | +} | ||
27 | + | ||
28 | +bool is_word(const byte endKind){ | ||
29 | + return end_Kind!=0; | ||
30 | +} | ||
12 | 31 | ||
13 | -int hash2(char c){ | ||
14 | - //needs to check isalpha==true | ||
15 | - if(c<='Z') | ||
16 | - return c-'A'; | ||
17 | - return c-'a'+26; | 32 | +bool addto_dico(dico d,string s){ |
33 | + if(is_word() | ||
18 | } | 34 | } |
19 | -bool addto_dico(dico,string){} |
@@ -3,15 +3,15 @@ | @@ -3,15 +3,15 @@ | ||
3 | 3 | ||
4 | #include "treeh.h" | 4 | #include "treeh.h" |
5 | 5 | ||
6 | -#define NB1CHAR 52 // A-Z + a-z | ||
7 | - | ||
8 | -typedef tree dico[NB1CHAR]; | 6 | +typedef tree dico[NBCHAR]; |
9 | 7 | ||
10 | void make_empty_dico(dico); | 8 | void make_empty_dico(dico); |
11 | void delete_dico(dico); | 9 | void delete_dico(dico); |
12 | -int hash2(char);//needs to check isalpha==true | ||
13 | bool addto_dico(dico,string); | 10 | bool addto_dico(dico,string); |
14 | 11 | ||
12 | +bool is_word(byte endKind);//pass end_kind() as parameter | ||
13 | +byte end_kind(string); | ||
14 | + | ||
15 | void loadfrom_file(dico,FILE*); | 15 | void loadfrom_file(dico,FILE*); |
16 | void loadfrom_keyboard(dico); | 16 | void loadfrom_keyboard(dico); |
17 | 17 |