PocketSphinx 5prealpha
dict2pid.h File Reference

Building triphones for a dictionary. More...

#include <stdio.h>
#include <sphinxbase/logmath.h>
#include <sphinxbase/bitvec.h>
#include "s3types.h"
#include "bin_mdef.h"
#include "dict.h"

Go to the source code of this file.

Data Structures

struct  xwdssid_t
 cross word triphone model structure More...
struct  dict2pid_t
 Building composite triphone (as well as word internal triphones) with the dictionary. More...

Macros

#define dict2pid_rssid(d, ci, lc)
 Access macros; not designed for arbitrary use.
#define dict2pid_ldiph_lc(d, b, r, l)
#define dict2pid_lrdiph_rc(d, b, l, r)

Functions

dict2pid_tdict2pid_build (bin_mdef_t *mdef, dict_t *dict)
 Build the dict2pid structure for the given model/dictionary.
dict2pid_tdict2pid_retain (dict2pid_t *d2p)
 Retain a pointer to dict2pid.
int dict2pid_free (dict2pid_t *d2p)
 Free the memory dict2pid structure.
s3ssid_t dict2pid_internal (dict2pid_t *d2p, int32 wid, int pos)
 Return the senone sequence ID for the given word position.
int dict2pid_add_word (dict2pid_t *d2p, int32 wid)
 Add a word to the dict2pid structure (after adding it to dict).
void dict2pid_dump (FILE *fp, dict2pid_t *d2p)
 For debugging.
void dict2pid_report (dict2pid_t *d2p)
 Report a dict2pid data structure.
int32 get_rc_nssid (dict2pid_t *d2p, s3wid_t w)
 Get number of rc.
s3cipid_tdict2pid_get_rcmap (dict2pid_t *d2p, s3wid_t w)
 Get RC map.

Detailed Description

Building triphones for a dictionary.

This is one of the more complicated parts of a cross-word triphone model decoder. The first and last phones of each word get their left and right contexts, respectively, from other words. For single-phone words, both its contexts are from other words, simultaneously. As these words are not known beforehand, life gets complicated.

Definition in file dict2pid.h.

Macro Definition Documentation

◆ dict2pid_ldiph_lc

#define dict2pid_ldiph_lc ( d,
b,
r,
l )
Value:
((d)->ldiph_lc[b][r][l])

Definition at line 116 of file dict2pid.h.

◆ dict2pid_lrdiph_rc

#define dict2pid_lrdiph_rc ( d,
b,
l,
r )
Value:
((d)->lrdiph_rc[b][l][r])

Definition at line 117 of file dict2pid.h.

◆ dict2pid_rssid

#define dict2pid_rssid ( d,
ci,
lc )
Value:
(&(d)->rssid[ci][lc])

Access macros; not designed for arbitrary use.

Definition at line 115 of file dict2pid.h.

Referenced by ngram_search_alloc_all_rc(), ngram_search_exit_score(), ngram_search_save_bp(), and ps_alignment_populate().

Function Documentation

◆ dict2pid_add_word()

int dict2pid_add_word ( dict2pid_t * d2p,
int32 wid )

◆ dict2pid_build()

dict2pid_t * dict2pid_build ( bin_mdef_t * mdef,
dict_t * dict )

Build the dict2pid structure for the given model/dictionary.

Parameters
mdefA model definition
dictAn initialized dictionary

Definition at line 388 of file dict2pid.c.

References BAD_S3SSID, dict2pid_t::dict, dict2pid_report(), dict_pron, dict_size, dict2pid_t::ldiph_lc, dict2pid_t::lrdiph_rc, dict2pid_t::mdef, bin_mdef_s::n_ciphone, WORD_POSN_BEGIN, and WORD_POSN_END.

Referenced by ps_load_dict(), and ps_reinit().

◆ dict2pid_dump()

void dict2pid_dump ( FILE * fp,
dict2pid_t * d2p )

For debugging.

Parameters
fpIn: a file pointer
d2pIn: a dict2pid_t structure

Definition at line 538 of file dict2pid.c.

References dict2pid_t::dict, dict2pid_internal(), dict_size, dict2pid_t::ldiph_lc, dict2pid_t::mdef, bin_mdef_s::n_sseq, and bin_mdef_s::sseq.

◆ dict2pid_free()

int dict2pid_free ( dict2pid_t * d2p)

Free the memory dict2pid structure.

Parameters
d2pIn: the d2p

Definition at line 507 of file dict2pid.c.

References dict2pid_t::dict, dict2pid_t::ldiph_lc, dict2pid_t::lrdiph_rc, dict2pid_t::lrssid, dict2pid_t::mdef, and dict2pid_t::rssid.

Referenced by ps_alignment_free(), ps_free(), ps_load_dict(), ps_reinit(), ps_search_base_free(), and ps_search_base_reinit().

◆ dict2pid_get_rcmap()

s3cipid_t * dict2pid_get_rcmap ( dict2pid_t * d2p,
s3wid_t w )

Get RC map.

Parameters
d2pIn: a dict2pid
wIn: a wid

Definition at line 229 of file dict2pid.c.

References xwdssid_t::cimap, dictword_t::ciphone, dict2pid_t::dict, dict2pid_t::lrssid, dictword_t::pronlen, dict2pid_t::rssid, and dict_t::word.

◆ dict2pid_internal()

s3ssid_t dict2pid_internal ( dict2pid_t * d2p,
int32 wid,
int pos )

Return the senone sequence ID for the given word position.

Definition at line 367 of file dict2pid.c.

References BAD_S3SSID, dict2pid_t::dict, dict_pron, dict2pid_t::mdef, and WORD_POSN_INTERNAL.

Referenced by dict2pid_dump(), and ps_alignment_populate().

◆ dict2pid_report()

void dict2pid_report ( dict2pid_t * d2p)

Report a dict2pid data structure.

Parameters
d2pIn: a dict2pid_t structure

Definition at line 533 of file dict2pid.c.

Referenced by dict2pid_build().

◆ dict2pid_retain()

dict2pid_t * dict2pid_retain ( dict2pid_t * d2p)

Retain a pointer to dict2pid.

Definition at line 500 of file dict2pid.c.

Referenced by ps_alignment_init(), ps_search_base_reinit(), and ps_search_init().

◆ get_rc_nssid()

int32 get_rc_nssid ( dict2pid_t * d2p,
s3wid_t w )

Get number of rc.

Get number of rc.

I doubt whether it is correct because the compressed map has not been checked.

Parameters
d2pIn: a dict2pid
wIn: a wid

Definition at line 204 of file dict2pid.c.

References dictword_t::ciphone, dict2pid_t::dict, dict2pid_t::lrssid, xwdssid_t::n_ssid, dictword_t::pronlen, dict2pid_t::rssid, and dict_t::word.