// file: wrd_cstr_3.cc
//
 
// isip include files
//
#include "word.h"
#include "word_constants.h"
 
// method: constructor
//
// arguments:
//  int_4 index : (input) the word index
//  char_1* name_a : (input) word name
//  int_4 num_ph: (input) number of phones in this pronunciation
//  int_4* phones: (input) array of phones for this prnunciation
//
// return: none
//
// this is an overloaded constructor
//
Word::Word(int_4 index_a, char_1* name_a, int_4 num_ph_a, int_4* phones_a) {
  
  // set the word index
  //
  index_d = index_a;
  
  // set the word name
  //
  name_d = new char_1[strlen((char*)name_a) + (int_4)1];
  strcpy((char*)name_d, (char*)name_a);
  
  // initialize pronunciation arrays
  //
  num_prons_d = (int_4)0;
  num_phones_d = (int_4*)NULL;
  phone_list_d = (int_4**)NULL;
  
  // assign the pronunciations if valid
  //
  if (num_ph_a > (int_4)0) {

    // update number of pronunciations
    //
    num_prons_d = (int_4)1;

    // create memory
    //
    num_phones_d = new int_4[num_prons_d];
    phone_list_d = new int_4*[num_prons_d];

    // copy the pronunciations
    //
    for (int_4 i = 0; i < num_prons_d; i++) {
      num_phones_d[i] = num_ph_a;
      phone_list_d[i] = new int_4[num_phones_d[i]];
      for (int_4 j = 0; j < num_phones_d[i]; j++) {
	phone_list_d[i][j] = phones_a[j];
      }
    }
  }

  // set the status flag
  //
  active_d = ISIP_FALSE;
  
  // exit gracefully
  //
}
