PocketSphinx 5prealpha
|
N-Gram based multi-pass search ("FBS") More...
#include <sphinxbase/cmd_ln.h>
#include <sphinxbase/logmath.h>
#include <sphinxbase/ngram_model.h>
#include <sphinxbase/listelem_alloc.h>
#include <sphinxbase/err.h>
#include "pocketsphinx_internal.h"
#include "hmm.h"
Go to the source code of this file.
Data Structures | |
struct | chan_s |
Lexical tree node data type. More... | |
struct | root_chan_s |
Lexical tree node data type for the first phone (root) of each dynamic HMM tree structure. More... | |
struct | bptbl_s |
Back pointer table (forward pass lattice; actually a tree) More... | |
struct | bptbl_seg_s |
Segmentation "iterator" for backpointer table results. More... | |
struct | lastphn_cand_s |
struct | last_ltrans_t |
struct | cand_sf_t |
struct | bestbp_rc_s |
struct | ngram_search_stats_s |
Various statistics for profiling. More... | |
struct | ngram_search_s |
N-Gram search module structure. More... | |
Macros | |
#define | CAND_SF_ALLOCSIZE 32 |
#define | NO_BP -1 |
Typedefs | |
typedef struct chan_s | chan_t |
Lexical tree node data type. More... | |
typedef struct root_chan_s | root_chan_t |
Lexical tree node data type for the first phone (root) of each dynamic HMM tree structure. More... | |
typedef struct bptbl_s | bptbl_t |
Back pointer table (forward pass lattice; actually a tree) | |
typedef struct bptbl_seg_s | bptbl_seg_t |
Segmentation "iterator" for backpointer table results. | |
typedef struct lastphn_cand_s | lastphn_cand_t |
typedef struct bestbp_rc_s | bestbp_rc_t |
typedef struct ngram_search_stats_s | ngram_search_stats_t |
Various statistics for profiling. | |
typedef struct ngram_search_s | ngram_search_t |
Functions | |
ps_search_t * | ngram_search_init (const char *name, ngram_model_t *lm, cmd_ln_t *config, acmod_t *acmod, dict_t *dict, dict2pid_t *d2p) |
Initialize the N-Gram search module. More... | |
void | ngram_search_free (ps_search_t *ngs) |
Finalize the N-Gram search module. More... | |
int | ngram_search_mark_bptable (ngram_search_t *ngs, int frame_idx) |
Record the current frame's index in the backpointer table. More... | |
void | ngram_search_save_bp (ngram_search_t *ngs, int frame_idx, int32 w, int32 score, int32 path, int32 rc) |
Enter a word in the backpointer table. More... | |
void | ngram_search_alloc_all_rc (ngram_search_t *ngs, int32 w) |
Allocate last phone channels for all possible right contexts for word w. More... | |
void | ngram_search_free_all_rc (ngram_search_t *ngs, int32 w) |
Allocate last phone channels for all possible right contexts for word w. More... | |
int | ngram_search_find_exit (ngram_search_t *ngs, int frame_idx, int32 *out_best_score) |
Find the best word exit for the current frame in the backpointer table. More... | |
char const * | ngram_search_bp_hyp (ngram_search_t *ngs, int bpidx) |
Backtrace from a given backpointer index to obtain a word hypothesis. More... | |
void | ngram_compute_seg_scores (ngram_search_t *ngs, float32 lwf) |
Compute language and acoustic scores for backpointer table entries. | |
ps_lattice_t * | ngram_search_lattice (ps_search_t *search) |
Construct a word lattice from the current hypothesis. More... | |
int32 | ngram_search_exit_score (ngram_search_t *ngs, bptbl_t *pbe, int rcphone) |
Get the exit score for a backpointer entry with a given right context. More... | |
void | ngram_search_set_lm (ngram_model_t *lm) |
Sets the global language model. More... | |
N-Gram based multi-pass search ("FBS")
Definition in file ngram_search.h.
#define CAND_SF_ALLOCSIZE 32 |
Definition at line 157 of file ngram_search.h.
#define NO_BP -1 |
Definition at line 175 of file ngram_search.h.
Lexical tree node data type.
Not the first HMM for words, which multiplex HMMs based on different left contexts. This structure is used both in the dynamic HMM tree structure and in the per-word last-phone right context fanout.
typedef struct ngram_search_s ngram_search_t |
Definition at line 358 of file ngram_search.h.
typedef struct root_chan_s root_chan_t |
Lexical tree node data type for the first phone (root) of each dynamic HMM tree structure.
Each state may have a different parent static HMM. Most fields are similar to those in chan_t.
void ngram_search_alloc_all_rc | ( | ngram_search_t * | ngs, |
int32 | w | ||
) |
Allocate last phone channels for all possible right contexts for word w.
Definition at line 598 of file ngram_search.c.
References ngram_search_s::chan_alloc, chan_s::ciphone, dict2pid_rssid, chan_s::hmm, ngram_search_s::hmmctx, xwdssid_t::n_ssid, chan_s::next, chan_s::rc_id, xwdssid_t::ssid, and ngram_search_s::word_chan.
char const * ngram_search_bp_hyp | ( | ngram_search_t * | ngs, |
int | bpidx | ||
) |
Backtrace from a given backpointer index to obtain a word hypothesis.
Definition at line 550 of file ngram_search.c.
References bptbl_s::bp, ps_search_s::hyp_str, and bptbl_s::wid.
int32 ngram_search_exit_score | ( | ngram_search_t * | ngs, |
bptbl_t * | pbe, | ||
int | rcphone | ||
) |
Get the exit score for a backpointer entry with a given right context.
Definition at line 660 of file ngram_search.c.
References xwdssid_t::cimap, dict2pid_rssid, bptbl_s::last2_phone, bptbl_s::last_phone, bptbl_s::s_idx, and bptbl_s::score.
Referenced by ngram_search_lattice().
int ngram_search_find_exit | ( | ngram_search_t * | ngs, |
int | frame_idx, | ||
int32 * | out_best_score | ||
) |
Find the best word exit for the current frame in the backpointer table.
Definition at line 506 of file ngram_search.c.
References BETTER_THAN, ngram_search_s::n_frame, bptbl_s::score, bptbl_s::wid, and WORST_SCORE.
void ngram_search_free | ( | ps_search_t * | ngs | ) |
Finalize the N-Gram search module.
Definition at line 289 of file ngram_search.c.
References ngram_search_s::active_word_list, ngram_search_s::chan_alloc, ngram_search_s::hmmctx, ngram_search_s::latnode_alloc, ngram_search_s::lmset, ngram_fwdflat_deinit(), ngram_fwdtree_deinit(), ngram_search_s::root_chan_alloc, ngram_search_s::word_active, and ngram_search_s::word_chan.
Referenced by ngram_search_init().
void ngram_search_free_all_rc | ( | ngram_search_t * | ngs, |
int32 | w | ||
) |
Allocate last phone channels for all possible right contexts for word w.
Definition at line 647 of file ngram_search.c.
References ngram_search_s::chan_alloc, chan_s::hmm, chan_s::next, and ngram_search_s::word_chan.
Referenced by ngram_fwdtree_finish().
ps_search_t * ngram_search_init | ( | const char * | name, |
ngram_model_t * | lm, | ||
cmd_ln_t * | config, | ||
acmod_t * | acmod, | ||
dict_t * | dict, | ||
dict2pid_t * | d2p | ||
) |
Initialize the N-Gram search module.
Definition at line 140 of file ngram_search.c.
References acmod_set_grow(), ngram_search_s::active_word_list, ngram_search_s::chan_alloc, dict_size, ngram_search_s::hmmctx, ngram_search_s::latnode_alloc, ngram_search_s::lmset, acmod_s::mdef, ngram_search_s::n_frame_alloc, ngram_fwdflat_init(), ngram_fwdtree_init(), ngram_search_free(), ngram_search_s::root_chan_alloc, bin_mdef_s::sseq, acmod_s::tmat, tmat_t::tp, ngram_search_s::word_active, and ngram_search_s::word_chan.
Referenced by ps_set_lm().
ps_lattice_t * ngram_search_lattice | ( | ps_search_t * | search | ) |
Construct a word lattice from the current hypothesis.
Definition at line 1215 of file ngram_search.c.
References ps_latnode_s::alt, ps_latnode_s::basewid, ngram_search_s::best_score, BETTER_THAN, ps_search_s::dag, ps_search_s::dict, ps_lattice_s::end, ps_latnode_s::fef, ps_lattice_s::final_node_ascr, bptbl_s::frame, ps_lattice_s::latnode_alloc, ps_latnode_s::lef, ngram_search_s::n_frame, ps_lattice_s::n_frames, ps_lattice_s::n_nodes, ps_latnode_s::next, ngram_search_exit_score(), ps_lattice_s::nodes, ps_lattice_delete_unreachable(), ps_lattice_free(), ps_lattice_init_search(), ps_lattice_link(), ps_lattice_penalize_fillers(), ps_latnode_s::reachable, bptbl_s::score, ps_latnode_s::sf, ps_lattice_s::start, bptbl_s::wid, ps_latnode_s::wid, WORSE_THAN, and WORST_SCORE.
int ngram_search_mark_bptable | ( | ngram_search_t * | ngs, |
int | frame_idx | ||
) |
Record the current frame's index in the backpointer table.
Definition at line 329 of file ngram_search.c.
References ngram_search_s::frm_wordlist, and ngram_search_s::n_frame_alloc.
Referenced by ngram_fwdflat_finish(), ngram_fwdflat_search(), ngram_fwdtree_finish(), and ngram_fwdtree_search().
void ngram_search_save_bp | ( | ngram_search_t * | ngs, |
int | frame_idx, | ||
int32 | w, | ||
int32 | score, | ||
int32 | path, | ||
int32 | rc | ||
) |
Enter a word in the backpointer table.
Definition at line 383 of file ngram_search.c.
References bptbl_s::bp, dict2pid_rssid, bptbl_s::frame, bptbl_s::last2_phone, bptbl_s::last_phone, bptbl_s::prev_real_wid, bptbl_s::real_wid, bptbl_s::s_idx, bptbl_s::score, bptbl_s::valid, bptbl_s::wid, WORSE_THAN, and WORST_SCORE.
void ngram_search_set_lm | ( | ngram_model_t * | lm | ) |
Sets the global language model.
Sets the language model to use if nothing was passed in configuration
Definition at line 1403 of file ngram_search.c.