Go to the documentation of this file.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
00036
00037
00038 #ifndef _S3_DICT_H_
00039 #define _S3_DICT_H_
00040
00044 #include <hash_table.h>
00045 #include <s3types.h>
00046
00047 #include "bin_mdef.h"
00048 #include "pocketsphinx_export.h"
00049
00050 #define S3DICT_INC_SZ 4096
00051
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 #if 0
00056 }
00057 #endif
00058
00063 typedef struct {
00064 char *word;
00065 s3cipid_t *ciphone;
00066 int32 pronlen;
00067 s3wid_t alt;
00068 s3wid_t basewid;
00069 } dictword_t;
00070
00076 typedef struct {
00077 int refcnt;
00078 bin_mdef_t *mdef;
00079 dictword_t *word;
00080 hash_table_t *ht;
00081 int32 max_words;
00082 int32 n_word;
00083 int32 filler_start;
00084 int32 filler_end;
00085 s3wid_t startwid;
00086 s3wid_t finishwid;
00087 s3wid_t silwid;
00088 int nocase;
00089 } dict_t;
00090
00091
00097 dict_t *dict_init(cmd_ln_t *config,
00098 bin_mdef_t *mdef
00099 );
00100
00104 int dict_write(dict_t *dict, char const *filename, char const *format);
00105
00107 POCKETSPHINX_EXPORT
00108 s3wid_t dict_wordid(dict_t *d, const char *word);
00109
00114 int dict_filler_word(dict_t *d,
00115 s3wid_t w
00116 );
00117
00121 POCKETSPHINX_EXPORT
00122 int dict_real_word(dict_t *d,
00123 s3wid_t w
00124 );
00125
00130 s3wid_t dict_add_word(dict_t *d,
00131 char const *word,
00132 s3cipid_t const *p,
00133 int32 np
00134 );
00135
00139 const char *dict_ciphone_str(dict_t *d,
00140 s3wid_t wid,
00141 int32 pos
00142 );
00143
00145 #define dict_size(d) ((d)->n_word)
00146 #define dict_num_fillers(d) (dict_filler_end(d) - dict_filler_start(d))
00147
00152 #define dict_num_real_words(d) \
00153 (dict_size(d) - (dict_filler_end(d) - dict_filler_start(d)) - 2)
00154 #define dict_basewid(d,w) ((d)->word[w].basewid)
00155 #define dict_wordstr(d,w) ((d)->word[w].word)
00156 #define dict_basestr(d,w) ((d)->word[dict_basewid(d,w)].word)
00157 #define dict_nextalt(d,w) ((d)->word[w].alt)
00158 #define dict_pronlen(d,w) ((d)->word[w].pronlen)
00159 #define dict_pron(d,w,p) ((d)->word[w].ciphone[p])
00160 #define dict_filler_start(d) ((d)->filler_start)
00161 #define dict_filler_end(d) ((d)->filler_end)
00162 #define dict_startwid(d) ((d)->startwid)
00163 #define dict_finishwid(d) ((d)->finishwid)
00164 #define dict_silwid(d) ((d)->silwid)
00165 #define dict_is_single_phone(d,w) ((d)->word[w].pronlen == 1)
00166 #define dict_first_phone(d,w) ((d)->word[w].ciphone[0])
00167 #define dict_second_phone(d,w) ((d)->word[w].ciphone[1])
00168 #define dict_second_last_phone(d,w) ((d)->word[w].ciphone[(d)->word[w].pronlen - 2])
00169 #define dict_last_phone(d,w) ((d)->word[w].ciphone[(d)->word[w].pronlen - 1])
00170
00171
00172 #define S3_START_WORD "<s>"
00173 #define S3_FINISH_WORD "</s>"
00174 #define S3_SILENCE_WORD "<sil>"
00175 #define S3_UNKNOWN_WORD "<UNK>"
00176
00184 int32 dict_word2basestr(char *word);
00185
00189 dict_t *dict_retain(dict_t *d);
00190
00194 int dict_free(dict_t *d);
00195
00197 void dict_report(dict_t *d
00198 );
00199
00200 #if 0
00201 {
00202 #endif
00203 #ifdef __cplusplus
00204 }
00205 #endif
00206
00207 #endif