Logo Search packages:      
Sourcecode: apertium version File versions  Download package

TaggerWord * MorphoStream2::get_next_word (  ) 

Get next word in the input strem

Returns:
A pointer to the next word in the input stream

Definition at line 60 of file MorphoStream2.C.

Referenced by HMM2::init_probabilities_from_tagged_text(), HMM2::init_probabilities_kupiec(), HMM2::read_dictionary(), HMM2::tagger(), and HMM2::train().

{
  if(vwords.size() != 0)
  {
    TaggerWord* word=vwords.front();
    vwords.erase(vwords.begin());
//    cout << *word << endl;
    return word;
  }

  if(feof(input))
  {
    return NULL;
  }
  
  int ivwords = 0;
  vwords.push_back(new TaggerWord());

  while(true)
  {
    int symbol = fgetc_unlocked(input);
    if(feof(input))
    {
      vwords[ivwords]->add_tag(ca_tag_keof, "", td->getPreferRules());
      return get_next_word();
    }
    if(symbol == '^')
    {
      readRestOfWord(ivwords);
      return get_next_word();
    }
    else
    {
      string str = "";
      str += static_cast<char>(symbol);

      while(symbol != '^')
      {
      symbol = fgetc_unlocked(input);
      if(feof(input))
      {
        vwords[ivwords]->add_ignored_string(str);
          vwords[ivwords]->add_tag(ca_tag_keof, "", td->getPreferRules());
        return get_next_word();
      }
      else if(symbol == '\\')
      {
        str += '\\';
          symbol = fgetc_unlocked(input);
        if(feof(input))
        {
          vwords[ivwords]->add_ignored_string(str);
            vwords[ivwords]->add_tag(ca_tag_keof, "", td->getPreferRules());
          return get_next_word();
        }
        str += static_cast<char>(symbol);
      }
      else if(symbol == '^')
      {
        if(str.size() > 0)
        {
          vwords[ivwords]->add_ignored_string(str);
          }
        readRestOfWord(ivwords);
        return get_next_word();
      }
        else
      {
        str += static_cast<char>(symbol);
      }
      }
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index