PocketSphinx  5prealpha
dict2pid.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2014 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 
38 #ifndef _S3_DICT2PID_H_
39 #define _S3_DICT2PID_H_
40 
41 /* System headers. */
42 #include <stdio.h>
43 
44 /* SphinxBase headers. */
45 #include <sphinxbase/logmath.h>
46 #include <sphinxbase/bitvec.h>
47 
48 /* Local headers. */
49 #include "s3types.h"
50 #include "bin_mdef.h"
51 #include "dict.h"
52 
64 #ifdef __cplusplus
65 extern "C" {
66 #endif
67 
73 typedef struct {
74  s3ssid_t *ssid;
76  int32 n_ssid;
77 } xwdssid_t;
78 
84 typedef struct {
85  int refcount;
86 
91  /*Notice the order of the arguments */
92  /* FIXME: This is crying out for compression - in Mandarin we have
93  * 180 context independent phones, which makes this an 11MB
94  * array. */
95  s3ssid_t ***ldiph_lc;
105  s3ssid_t ***lrdiph_rc;
112 } dict2pid_t;
113 
115 #define dict2pid_rssid(d,ci,lc) (&(d)->rssid[ci][lc])
116 #define dict2pid_ldiph_lc(d,b,r,l) ((d)->ldiph_lc[b][r][l])
117 #define dict2pid_lrdiph_rc(d,b,l,r) ((d)->lrdiph_rc[b][l][r])
118 
123  dict_t *dict
124  );
125 
130 
134 int dict2pid_free(dict2pid_t *d2p
135  );
136 
140 s3ssid_t dict2pid_internal(dict2pid_t *d2p,
141  int32 wid,
142  int pos);
143 
148  int32 wid);
149 
153 void dict2pid_dump(FILE *fp,
154  dict2pid_t *d2p
155  );
156 
158 void dict2pid_report(dict2pid_t *d2p
159  );
160 
164 int32 get_rc_nssid(dict2pid_t *d2p,
165  s3wid_t w
166  );
167 
172  s3wid_t w
173  );
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 
180 #endif
Operations on dictionary.
s3ssid_t *** ldiph_lc
For multi-phone words, [base][rc][lc] -&gt; ssid; filled out for word-initial base x rc combinations in ...
Definition: dict2pid.h:95
int32 n_ssid
#Unique ssid in above, compressed ssid list
Definition: dict2pid.h:76
Binary format model definition files, with support for heterogeneous topologies and variable-size N-p...
xwdssid_t ** rssid
Right context state sequence id table First dimension: base phone, Second dimension: left context...
Definition: dict2pid.h:99
void dict2pid_report(dict2pid_t *d2p)
Report a dict2pid data structure.
Definition: dict2pid.c:533
int dict2pid_free(dict2pid_t *d2p)
Free the memory dict2pid structure.
Definition: dict2pid.c:507
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition: s3types.h:63
bin_mdef_t * mdef
Model definition, used to generate internal ssids on the fly.
Definition: dict2pid.h:87
int dict2pid_add_word(dict2pid_t *d2p, int32 wid)
Add a word to the dict2pid structure (after adding it to dict).
Definition: dict2pid.c:298
Size definition of semantically units.
s3ssid_t *** lrdiph_rc
For single-phone words, [base][lc][rc] -&gt; ssid; filled out for single-phone base x lc combinations in...
Definition: dict2pid.h:105
dict_t * dict
Dictionary this table refers to.
Definition: dict2pid.h:89
a structure for a dictionary.
Definition: dict.h:76
void dict2pid_dump(FILE *fp, dict2pid_t *d2p)
For debugging.
Definition: dict2pid.c:538
s3ssid_t dict2pid_internal(dict2pid_t *d2p, int32 wid, int pos)
Return the senone sequence ID for the given word position.
Definition: dict2pid.c:367
cross word triphone model structure
Definition: dict2pid.h:73
dict2pid_t * dict2pid_retain(dict2pid_t *d2p)
Retain a pointer to dict2pid.
Definition: dict2pid.c:500
xwdssid_t ** lrssid
Left-Right context state sequence id table First dimension: base phone, Second dimension: left contex...
Definition: dict2pid.h:108
s3cipid_t * dict2pid_get_rcmap(dict2pid_t *d2p, s3wid_t w)
Get RC map.
Definition: dict2pid.c:229
int32 get_rc_nssid(dict2pid_t *d2p, s3wid_t w)
ARCHAN, A duplicate of get_rc_npid in ctxt_table.h.
Definition: dict2pid.c:204
dict2pid_t * dict2pid_build(bin_mdef_t *mdef, dict_t *dict)
Build the dict2pid structure for the given model/dictionary.
Definition: dict2pid.c:388
s3cipid_t * cimap
Index into ssid[] above for each ci phone.
Definition: dict2pid.h:75
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:84
s3ssid_t * ssid
Senone Sequence ID list for all context ciphones.
Definition: dict2pid.h:74