コード例 #1
0
ファイル: HLVRec-misc.c プロジェクト: 2hanson/voice_dialling
/* CheckTokenSetOrder

     check whether the relTokens are sorted by LMState order 
*/
void CheckTokenSetOrder (DecoderInst *dec, TokenSet *ts)
{
   int i;
   RelToken *prevTok;
   Boolean ok = TRUE;

   prevTok = &ts->relTok[0];
   for (i = 1; i < ts->n; ++i) {
      if (TOK_LMSTATE_LT(&ts->relTok[i], prevTok) || TOK_LMSTATE_EQ(&ts->relTok[i], prevTok))
         ok = FALSE;
      prevTok = &ts->relTok[i];
   }

   if (!ok) {
      printf ("XXXXX CheckTokenSetOrder \n");
      PrintTokSet (dec, ts);
      abort();
   }
}
コード例 #2
0
void Decoder::FindWinningTokens(TokenSet *src, TokenSet *dest, LogFloat score,
    RelTokScore srcCorr, RelTokScore destCorr, RelTokScore deltaLimit,
    RelToken* &winTok, int &nWinTok, int* nWin) {

  auto srcTok = src->relTok,
       destTok = dest->relTok;

  int nSrcTok = src->n, nDestTok = dest->n;
  int winLoc;
  do {
    if (TOK_LMSTATE_EQ(srcTok, destTok)) {
      /* pick winner */
      if (src->score + srcTok->delta + score > dest->score + destTok->delta) {
	/* store srcTok */
	winTok[nWinTok] = *srcTok;
	winTok[nWinTok].delta += srcCorr + score;
	winLoc = 0;
      } else {
	/* store destTok */
	winTok[nWinTok] = *destTok;
	winTok[nWinTok].delta += destCorr;
	winLoc = 1;
      }
      ++srcTok;
      --nSrcTok;
      ++destTok;
      --nDestTok;
    } else if (TOK_LMSTATE_LT(srcTok, destTok)) {
      /* store srcTok */
      winTok[nWinTok] = *srcTok;
      winTok[nWinTok].delta += srcCorr + score;
      winLoc = 0;
      ++srcTok;
      --nSrcTok;
    } else {
      /* store destTok */
      winTok[nWinTok] = *destTok;
      winTok[nWinTok].delta += destCorr;
      winLoc = 1;
      ++destTok;
      --nDestTok;
    }

    if (winTok[nWinTok].delta >= deltaLimit) {      /* keep or prune? */
      ++nWinTok;
      ++nWin[winLoc];
    }

  } while (nSrcTok != 0 && nDestTok != 0);

  /* Add left overs to winTok set, only at most one of the two loops will
   * actually do something */
  for (int i = nSrcTok; i > 0; --i, ++srcTok) {
    winTok[nWinTok] = *srcTok;
    winTok[nWinTok].delta += srcCorr + score;
    if (winTok[nWinTok].delta >= deltaLimit) {     /* keep or prune? */
      ++nWinTok;
      ++nWin[0];
    }
  }

  for (int i = nDestTok; i > 0; --i, ++destTok) {
    winTok[nWinTok] = *destTok;
    winTok[nWinTok].delta += destCorr;
    if (winTok[nWinTok].delta >= deltaLimit) {     /* keep or prune? */
      ++nWinTok;
      ++nWin[1];
    }
  }
}