To implement this, modify HLVLM.c to initialise the array immediately
after creating it:
nglm->unigrams = (NGLM_Prob *) New (nglm->heap, (nglm->vocSize + 1) *
sizeof (NGLM_Prob));
for (i=0;i<(nglm->vocSize + 1);i++){
nglm->unigrams[i] = NGLM_PROB_LZERO;
}
This solution, however caused me to find a second bug. There is no check
whether the NGLM_Prob which is an unsigned short overflows (ie. 65535 +
3000 = 2999).
To fix this I created a new macro in HLVLM.h:
#define
NGLM_PROB_ADD(x,y)((((NGLM_Prob)((x)+(y))<(x))||((NGLM_Prob)((x)+(y))<(y)))?NGLM_PROB_LZERO:((x)+(y)))
(I don't think that the "or" condition or the second comparison is
actually necessary but it fixes the problem)
All additions of NGLM_Prob variables should then be replaced by the
above macro. I believe that this only occurs in HLVLM.c.
I am starting from a non-standard version of HDecode so I haven't
included diffs but I can send the modified files if required.