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
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _DICT_H_
00036 #define _DICT_H_
00037
00038
00039 #include <hash_table.h>
00040 #include <glist.h>
00041 #include <listelem_alloc.h>
00042 #include <cmd_ln.h>
00043
00044
00045 #include "bin_mdef.h"
00046
00047 #define NO_WORD -1
00048
00049
00050
00051
00052
00053
00054
00055 typedef struct dict_entry {
00056 char *word;
00057 int32 *phone_ids;
00058 int32 *ci_phone_ids;
00059 int16 len;
00060 int16 mpx;
00061 int32 wid;
00062 int32 alt;
00063 } dict_entry_t;
00064
00065 typedef struct dict_s {
00066 cmd_ln_t *config;
00067 bin_mdef_t *mdef;
00068 hash_table_t *dict;
00069 int32 dict_entry_count;
00070 listelem_alloc_t *dict_entry_alloc;
00071 dict_entry_t **dict_list;
00072 int32 ci_index_len;
00073 int32 *ci_index;
00074 int32 filler_start;
00075
00076 hash_table_t *lcHT;
00077 glist_t lcList;
00078 uint16 **lcFwdTable;
00079 uint16 **lcBwdTable;
00080 uint16 **lcBwdPermTable;
00081 uint16 *lcBwdSizeTable;
00082
00083 hash_table_t *rcHT;
00084 glist_t rcList;
00085 uint16 **rcFwdTable;
00086 uint16 **rcFwdPermTable;
00087 uint16 **rcBwdTable;
00088 uint16 *rcFwdSizeTable;
00089
00090 int32 initial_dummy;
00091 int32 first_dummy;
00092 int32 last_dummy;
00093 } dict_t;
00094
00095 dict_t *dict_init(cmd_ln_t *config,
00096 bin_mdef_t *mdef);
00097 void dict_free (dict_t *dict);
00098
00099 #define DICT_SILENCE_WORDSTR "<sil>"
00100
00101 int32 dict_to_id(dict_t *dict, char const *dict_str);
00102 int32 dict_add_word (dict_t *dict, char const *word, char *pron);
00103 int32 dict_pron (dict_t *dict, int32 w, int32 **pron);
00104 int32 dict_next_alt (dict_t *dict, int32 w);
00105 int32 dict_get_num_main_words (dict_t *dict);
00106
00107
00108 int32 dict_is_filler_word (dict_t *dict, int32 wid);
00109
00110 #define dict_word_str(d,x) ((x == NO_WORD) ? "" : d->dict_list[x]->word)
00111
00112 #define dict_base_str(d,x) ((x == NO_WORD) ? "" : \
00113 d->dict_list[d->dict_list[x]->wid]->word)
00114 #define dict_base_wid(d,x) ((x == NO_WORD) ? NO_WORD : \
00115 d->dict_list[x]->wid)
00116
00117 #define dict_pronlen(dict,wid) ((dict)->dict_list[wid]->len)
00118 #define dict_ciphone(d,w,p) ((d)->dict_list[w]->ci_phone_ids[p])
00119 #define dict_phone(d,w,p) ((d)->dict_list[w]->phone_ids[p])
00120 #define dict_mpx(d,w) ((d)->dict_list[w]->mpx)
00121
00122 #define dict_n_words(d) ((d)->dict_entry_count)
00123
00124 #define dict_ciphone_id(d,p) \
00125 ((d)->dict->nocase \
00126 ? bin_mdef_ciphone_id_nocase((d)->mdef, (p)) \
00127 : bin_mdef_ciphone_id((d)->mdef, (p)))
00128 #endif