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
00042 #ifndef __PS_LATTICE_INTERNAL_H__
00043 #define __PS_LATTICE_INTERNAL_H__
00044
00053 typedef struct latlink_list_s {
00054 ps_latlink_t *link;
00055 struct latlink_list_s *next;
00056 } latlink_list_t;
00057
00061 struct ps_lattice_s {
00062 int refcount;
00064 ps_search_t *search;
00065 logmath_t *lmath;
00067 ps_latnode_t *nodes;
00068 ps_latnode_t *start;
00069 ps_latnode_t *end;
00071 int32 n_frames;
00072 int32 final_node_ascr;
00073 int32 norm;
00074 char *hyp_str;
00076 listelem_alloc_t *latnode_alloc;
00077 listelem_alloc_t *latlink_alloc;
00078 listelem_alloc_t *latlink_list_alloc;
00080
00081 latlink_list_t *q_head;
00082 latlink_list_t *q_tail;
00083 };
00084
00092 struct ps_latlink_s {
00093 struct ps_latnode_s *from;
00094 struct ps_latnode_s *to;
00095 struct ps_latlink_s *best_prev;
00096 int32 ascr;
00097 int32 path_scr;
00098 int32 ef;
00099 int32 alpha;
00100 int32 beta;
00101 };
00102
00109 struct ps_latnode_s {
00110 int32 id;
00111 int32 wid;
00112 int32 basewid;
00113
00114 int32 fef;
00115 int32 lef;
00116 int16 sf;
00117 int16 reachable;
00118 union {
00119 int32 fanin;
00120 int32 rem_score;
00121 int32 best_exit;
00122 } info;
00123 latlink_list_t *exits;
00124 latlink_list_t *entries;
00126 struct ps_latnode_s *alt;
00127 struct ps_latnode_s *next;
00128 };
00129
00133 typedef struct dag_seg_s {
00134 ps_seg_t base;
00135 ps_latlink_t **links;
00136 int32 norm;
00137 int16 n_links;
00138 int16 cur;
00139 } dag_seg_t;
00140
00147 typedef struct ps_latpath_s {
00148 ps_latnode_t *node;
00149 struct ps_latpath_s *parent;
00150 struct ps_latpath_s *next;
00151 int32 score;
00152 } ps_latpath_t;
00153
00157 typedef struct ps_astar_s {
00158 ps_lattice_t *dag;
00159 ngram_model_t *lmset;
00160 float32 lwf;
00161
00162 int16 sf;
00163 int16 ef;
00164 int32 w1;
00165 int32 w2;
00166
00167 int32 n_hyp_tried;
00168 int32 n_hyp_insert;
00169 int32 n_hyp_reject;
00170 int32 insert_depth;
00171 int32 n_path;
00172
00173 ps_latpath_t *path_list;
00174 ps_latpath_t *path_tail;
00175 ps_latpath_t *paths_done;
00176
00177 glist_t hyps;
00178 listelem_alloc_t *latpath_alloc;
00179 } ps_astar_t;
00180
00184 typedef struct astar_seg_s {
00185 ps_seg_t base;
00186 ps_latnode_t **nodes;
00187 int n_nodes;
00188 int cur;
00189 } astar_seg_t;
00190
00194 ps_lattice_t *ps_lattice_init_search(ps_search_t *search, int n_frame);
00195
00199 void ps_lattice_bypass_fillers(ps_lattice_t *dag, int32 silpen, int32 fillpen);
00200
00204 void ps_lattice_delete_unreachable(ps_lattice_t *dag);
00205
00209 void ps_lattice_pushq(ps_lattice_t *dag, ps_latlink_t *link);
00210
00214 ps_latlink_t *ps_lattice_popq(ps_lattice_t *dag);
00215
00219 void ps_lattice_delq(ps_lattice_t *dag);
00220
00224 latlink_list_t *latlink_list_new(ps_lattice_t *dag, ps_latlink_t *link,
00225 latlink_list_t *next);
00226
00230 char const *ps_lattice_hyp(ps_lattice_t *dag, ps_latlink_t *link);
00231
00235 ps_seg_t *ps_lattice_seg_iter(ps_lattice_t *dag, ps_latlink_t *link,
00236 float32 lwf);
00237
00247 ps_astar_t *ps_astar_start(ps_lattice_t *dag,
00248 ngram_model_t *lmset,
00249 float32 lwf,
00250 int sf, int ef,
00251 int w1, int w2);
00252
00258 ps_latpath_t *ps_astar_next(ps_astar_t *nbest);
00259
00263 void ps_astar_finish(ps_astar_t *nbest);
00264
00268 char const *ps_astar_hyp(ps_astar_t *nbest, ps_latpath_t *path);
00269
00273 ps_seg_t *ps_astar_seg_iter(ps_astar_t *astar, ps_latpath_t *path, float32 lwf);
00274
00275
00276 #endif