00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include <string.h>
00022 #include "general.h"
00023 #include "sih.h"
00024
00028 void read_wlist_into_siht(char *wlist_filename, int verbosity,
00029 sih_t *p_word_id_ht, int *p_n_wlist)
00030 {
00031 static char rname[]="read_wlist_into_siht";
00032 FILE *wlist_fp = rr_iopen(wlist_filename);
00033 char wlist_entry[1024], word[256], *word_copy;
00034 int entry_no = 0;
00035
00036 while (fgets (wlist_entry, sizeof (wlist_entry), wlist_fp)) {
00037 if (strncmp(wlist_entry,"##",2) == 0) continue;
00038 entry_no++;
00039 sscanf (wlist_entry, "%s ", word);
00040 if (strncmp(wlist_entry,"#",1)==0) {
00041 fprintf(stderr,"\n\n===========================================================\n");
00042 fprintf(stderr,"%s:\nWARNING: line assumed NOT a comment:\n",rname);
00043 fprintf(stderr, ">>> %s <<<\n",wlist_entry);
00044 fprintf(stderr, " '%s' will be included in the vocabulary\n",word);
00045 fprintf(stderr, " (comments must start with '##')\n");
00046 fprintf(stderr,"===========================================================\n\n");
00047 }
00048 word_copy = salloc(word);
00049 sih_add(p_word_id_ht, word_copy, entry_no);
00050 }
00051 rr_iclose(wlist_fp);
00052 if (verbosity)
00053 fprintf(stderr,"%s: a list of %d words was read from \"%s\".\n",
00054 rname,entry_no,wlist_filename);
00055 *p_n_wlist = entry_no;
00056 }