00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "config.h"
00028 #include <stdio.h>
00029 #include <stdlib.h>
00030 #include <string.h>
00031
00032 #include "dic.h"
00033 #include "regexp.h"
00034 #include "dic_search.h"
00035
00036
00037
00038
00039
00040 const unsigned int all_letter[DIC_LETTERS] =
00041 {
00042
00043
00044
00045 0,1,1,1,1, 1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1, 1, 1, 1, 1
00046 };
00047
00048 const unsigned int vowels[DIC_LETTERS] =
00049 {
00050
00051 0,1,0,0,0, 1,0,0,0,1,0, 0,0,0,0,1,0,0,0,0,0,1,0, 0, 0, 1, 0
00052 };
00053
00054 const unsigned int consonants[DIC_LETTERS] =
00055 {
00056
00057 0,0,1,1,1, 0,1,1,1,0,1, 1,1,1,1,0,1,1,1,1,1,0,1, 1, 1, 1, 1
00058 };
00059
00060 void init_letter_lists(struct search_RegE_list_t *list)
00061 {
00062 int i;
00063 memset (list,0,sizeof(*list));
00064 list->minlength = 1;
00065 list->maxlength = 15;
00066 list->valid[0] = 1;
00067 list->symbl[0] = RE_ALL_MATCH;
00068 list->valid[1] = 1;
00069 list->symbl[1] = RE_VOWL_MATCH;
00070 list->valid[2] = 1;
00071 list->symbl[2] = RE_CONS_MATCH;
00072 for(i=0; i < DIC_LETTERS; i++)
00073 {
00074 list->letters[0][i] = all_letter[i];
00075 list->letters[1][i] = vowels[i];
00076 list->letters[2][i] = consonants[i];
00077 }
00078 list->valid[3] = 0;
00079 list->symbl[3] = RE_USR1_MATCH;
00080 list->valid[4] = 0;
00081 list->symbl[4] = RE_USR2_MATCH;
00082 }
00083
00084
00085
00086
00087 void
00088 usage(int argc, char* argv[])
00089 {
00090 fprintf(stderr,"usage: %s dictionary\n",argv[0]);
00091 fprintf(stderr," dictionary : path to dawg eliot dictionary\n");
00092 }
00093
00094 int main(int argc, char* argv[])
00095 {
00096 int i;
00097 Dictionary dic;
00098 char wordlist[RES_REGE_MAX][DIC_WORD_MAX];
00099 char er[200];
00100 strcpy(er,".");
00101 struct search_RegE_list_t list;
00102
00103 if (argc < 2)
00104 {
00105 usage(argc,argv);
00106 }
00107
00108 if (Dic_load(&dic,argv[1]))
00109 {
00110 fprintf(stdout,"impossible de lire le dictionnaire\n");
00111 return 1;
00112 }
00113
00114 while (strcmp(er,""))
00115 {
00116 fprintf(stdout,"**************************************************************\n");
00117 fprintf(stdout,"**************************************************************\n");
00118 fprintf(stdout,"entrer une ER:\n");
00119 fgets(er,sizeof(er),stdin);
00120
00121 er[strlen(er) - 1] = '\0';
00122 if (strcmp(er,"") == 0)
00123 break;
00124
00125
00126 init_letter_lists(&list);
00127 Dic_search_RegE(dic,er,wordlist,&list);
00128
00129 fprintf(stdout,"résultat:\n");
00130 for(i=0; i<RES_REGE_MAX && wordlist[i][0]; i++)
00131 {
00132 fprintf(stderr,"%s\n",wordlist[i]);
00133 }
00134 }
00135
00136 Dic_destroy(dic);
00137 return 0;
00138 }