Exemple #1
0
void
Pst::
readPhsgt(ECString& path)
{
  ECString pstString(path);
  pstString += "pSgT.txt";
  ifstream pstStream(pstString.c_str());
  if(!pstStream)
    {
      cerr << "Could not find " << pstString << endl;
      assert(pstStream);
    }
  ignoreComment(pstStream);

  int numWords;
  pstStream >> numWords;
  hSize_ = numWords;
  h_ = new WordInfo[numWords];
  for(int i = 0 ; i < numWords ; i++)
    {
      ECString wrd;
      pstStream >> wrd;
      assert(pstStream);
      
      int ts[80];
      float ps[80];

      WordInfo& wi = h_[i];
      wi.n_ = i;
      wi.lexeme_ = wrd;
      int j;
      for(j = 0 ; ; j++)
	{
	  assert(j < 80);
	  ECString temp;
	  pstStream >> temp;
	  if(temp == "|")
	    {
	      pstStream >> wi.c_;
	      break;
	    }
	  ts[j] = atoi(temp.c_str());
	  pstStream >> ps[j];
	}
      wi.stSize_ = j;
      wi.st_ = new Phsgt[j];
      for(int k = 0 ; k < j ; k++)
	{
	  wi.st_[k].term = ts[k];
	  wi.st_[k].prob = ps[k];
	  wi.st_[k].classNum = 0;
	}
    }
Exemple #2
0
void
Pst::
readPhsgt(ECString& path)
{
  ECString pstString(path);
  pstString += "pSgT.txt";
  ifstream pstStream(pstString.c_str());
  if(!pstStream)
    {
      cerr << "Could not find " << pstString << endl;
      assert(pstStream);
    }
  ignoreComment(pstStream);

  int numWords;
  pstStream >> numWords;
  hSize_ = numWords;
  h_ = new WordInfo[numWords];
  for(int i = 0 ; i < numWords ; i++)
    {
      ECString wrd;
      pstStream >> wrd;
      assert(pstStream);
      
      int ts[80];
      float ps[80];

      WordInfo& wi = h_[i];
      wi.n_ = i;
      if (wrd == "**VocabHole**") {
          pstStream >> wrd; // actual word form
          wi.lexeme_ = wrd;
          wi.stSize_ = 0;
          wi.c_ = 0;
          wi.isVocabHole = true;
      }
      else { // real word