第一个介绍的是LabId的hashtable
#define HASHSIZE 250007 /* size of hash table */
static NameCell *hashtab[HASHSIZE]; /* the actual table */
一般HTK中的hash槽位存的都是指针,她们指向另一个结构体。这个hashtable的元素为Lable,它的解引用(*Lable),即为NameCell,其内容:
typedef struct _NameCell{ /* Hash Table Linked List Item */
char * name; /* Label Name */
Ptr aux; /* User pointer */
struct _NameCell *next; /* Chain */
}NameCell;
就是字符串,可以是HMM的名称,也可以是词(DictEntry)的名称。
一般通过GetLabId函数来返回这个结构指针,如果为NULL说明在hash表没有存对应的对象。
另一个哈希表,就是指向Macro的mtab:
MLink * mtab; /* Array[0..MACHASHSIZE-1]OF MLink */
typedef struct _MacroDef *MLink;
typedef struct _MacroDef{
MLink next; /* next cell in hash table */
char type; /* type of macro [hluvixdtmps*] */
short fidx; /* idx of MMF file (0 = SMF) */
LabId id; /* name of macro */
Ptr structure; /* -> shared structure or HMM Def */
} MacroDef;
它是作为HMMSet对象中一个数据项。通过hset->mtab的hash值来访问HMM/Marco对象,也是这里的Ptr指针指向的对象。
再一个就是词典每个入口的hash表:
Word *wtab; /* hash table for DictEntry's */
typedef struct _DictEntry *Word;
typedef struct _DictEntry{
LabId wordName; /* word identifier */
Pron pron; /* first pronunciation */
int nprons; /* number of prons for this word */
Word next; /* next word in hash table chain */
void *aux; /* hook used by HTK library modules for temp info */
} DictEntry;
它是词典vocab中一个数据项。也是通过LabId来计算hash值的。它的Pron是指针,指向发音对象WordPron,表明这个Word有几个读音,每个读音有哪几个音子。
在构建Lattice时,LNode就有关于发音的PronHolder对象,就是根据发音字典的Pron指针指向的WordPron来展开。
最后一个哈希表就是word end 表,它是在构建Network图时,最后一个发音音子指向一个word end节点。
/* Word end nodes are accessed through a hash table for fast access */
#define WNHASHSIZE 5701
static NetNode *wnHashTab[WNHASHSIZE];
/* The network nodes themselves just store connectivity info */
struct _NetNode {
NetNodeType type; /* Type of this node (includes context) */
union {
HLink hmm; /* HMM (physical) definition */
Pron pron; /* Word represented (may == null) */
}
info; /* Extra information specific to type of node */
char *tag; /* Semantic tagging information */
int nlinks; /* Number of nodes connected to this one */
NetLink *links; /* Array[0..nlinks-1] of links to connected nodes */
NetInst *inst; /* Model Instance (if one exists, else NULL) */
NetNode *chain;
int aux;
};
这个WordNode是由LArc的start节点的发音信息构建,也是它的inst指向start节点的pInst(PronHolder对象),且它的links指向LArc的ends节点。