Example #1
0
/* ReplaceUnigrams: replace unigrams in lm with ones from fn */
void ReplaceUnigrams(char *fn, BackOffLM *lm)
{
   float prob;
   SMEntry *se;
   NameId wdid;
   int ndx,nItem;
   FLEntry *root;
   char buf[MAXSTRLEN];
   Source src;

   nItem = 0;
   root = &lm->root;
   if(InitSource(fn,&src,NoFilter)<SUCCESS)
      HError(16910,"ReplaceUnigrams: Can't open file %s", fn);
   do {
      if (!ReadFloat(&src,&prob,1,FALSE)) break;
      if (!ReadRawString(&src,buf)) break; /* or ReadString if HTK escaped */
      if ((wdid = GetNameId(lm->htab,buf,FALSE))==NULL) {
         printf("skipping '%s'\n", buf);
         continue;
      }
      ndx = LM_INDEX(wdid); se = root->sea+ndx-1;
      if (se->ndx!=ndx && (se=FindSE(root->sea,0,root->nse,ndx))==NULL) {
         printf("ignoring '%s'\n", buf);
         continue;
      }
      se->prob = exp(prob*LN10);
      nItem++;
   } while(SkipLine(&src));
   CloseSource(&src);
   if (trace&T_TOP) {
      printf("Replaced %d unigrams from %s\n",nItem,uniFn); fflush(stdout);
   }
}
Example #2
0
// MMsgCommMRTGRequest::unpack
// Virtual method from MiniMessage.  Extracts data from message buffer.
void
MMsgCommMRTGRequest::Unpack(void)
{
    WTRACE("MMsgCommMRTGRequest::Unpack");
    MiniMessage::Unpack();

    if ((GetServiceType() != WONMsg::MiniCommonService) ||
            (GetMessageType() != WONMsg::MiniCommMRTGRequest))
    {
        WDBG_AH("MMsgCommMRTGRequest::Unpack Not a MiniCommMRTGRequest message!");
        throw WONMsg::BadMsgException(*this, __LINE__, __FILE__,
                                      "Not a MiniCommMRTGRequest message.");
    }
    WDBG_LL("MMsgCommMRTGRequest::Unpack Reading message data");
    mPrimaryID = ReadShort();
    mSecondaryID = ReadShort();
    ReadRawString(mPrimaryOption);
    ReadRawString(mSecondaryOption);
}
void SMsgFactSaveConfigFile::Unpack(void)
{
	WTRACE("SMsgFactSaveConfigFile::Unpack");
	SmallMessage::Unpack();

	if (GetServiceType() != WONMsg::SmallFactoryServer ||
	    GetMessageType() != WONMsg::FactSaveConfigFile)
	{
		WDBG_AH("SMsgFactSaveConfigFile::Unpack Not a FactSaveConfigFile message!");
		throw WONMsg::BadMsgException(*this, __LINE__, __FILE__, "Not a FactSaveConfigFile message!");
	}

	WDBG_LL("SMsgFactSaveConfigFile::Unpack Reading message data");

	ReadString(mConfigName);
	ReadString(mFilePath);
	ReadRawString(mBlob);
}
Example #4
0
void RoutingServerMessage::ReadClientName(ClientName& theBufR) const
{ ReadRawString(theBufR); }