diff --git a/dico_test b/dico_test index ca291e3..50a708d 100644 --- a/dico_test +++ b/dico_test @@ -1,7 +1,2 @@ -A -ba -aa' -abc -c -d' -aé \ No newline at end of file +Il est l'acteur-phare de l'émission télévisée humoristique Serviteur du peuple. Sans aucune expérience politique, il se présente pour le parti homonyme à l’élection présidentielle de 2019, qu'il remporte au second tour avec 73,2 % des voix, face au chef de l'État sortant, Petro Porochenko. À 41 ans, il est le plus jeune président élu en Ukraine. +test \ No newline at end of file diff --git a/main.c b/main.c index 8624150..a25bd9d 100644 --- a/main.c +++ b/main.c @@ -25,7 +25,7 @@ int main() wscanf(L"%ls",mot); wscanf(L"%d",&taille); int result; - result = find_mot(tab,mot,taille,0); + result = find_mot(tab,mot,taille,(int)mot[0]-97); printf("%d\n",result); diff --git a/tree.c b/tree.c index c902308..b41fc75 100644 --- a/tree.c +++ b/tree.c @@ -56,9 +56,9 @@ int size(wchar_t val[]) return cpt; } -void toLowerCase(wchar_t mot[],int size) +void toLowerCase(wchar_t mot[]) { - for(int i=0;i='A') { @@ -67,6 +67,15 @@ void toLowerCase(wchar_t mot[],int size) } } +void splitcarac(struct node **tab_ptr_tree,wchar_t message[]) +{ + if(message[0]<'a' || message[0]>'z')return; + + wchar_t *buffer; + wchar_t *token = wcstok(message, L" ,?;.:/!*+\\\"()=", &buffer); + add(tab_ptr_tree,token,size(token),(int)message[0]-97); + if(buffer!=NULL)splitcarac(tab_ptr_tree,buffer); +} void load_tree(FILE *fp, struct node **tab_ptr_tree) { @@ -75,12 +84,8 @@ void load_tree(FILE *fp, struct node **tab_ptr_tree) while(fwscanf(fp, L"%ls",val)==1) { - int taille = size(val); - toLowerCase(val,taille); - if(val[0]<'a' || val[0]>'z')continue; - //if(val[0]<97)val[0]+=32; - //val[0]-=97; - add(tab_ptr_tree,val,taille,(int)val[0]-97); + toLowerCase(val); + splitcarac(tab_ptr_tree,val); } //On peut tester la bonne ou mauvaise terminaison de la lecture -- libgit2 0.21.2