// file: bw_print_5.cc
//
// isip include files
//
#include "bw_train.h"
#include "bw_train_constants.h"

// method: print_occ_cc
//
// arguments:
//  char_1* file: (output) the states occupancy file
//  State** states : (input) the states
//  Phone** phones : (input) the phones
//  int_4 num_phones : (input) the number of phones
//  int_4 num_states : (input) the number of states
//  float_8* state_occ : (input) the state occupancy probabilities
//
// return: a logical flag to indicate success
//

// this method writes the state occupancies into a file
//
logical_1 print_occ_cc(char_1* file_a, Train_State** states_a, Train_Phone** phones_a,
		       int_4 num_phones_a, int_4 num_states_a,
		       float_8* state_occ_a) {
  // open the file
  //
  FILE* f_st = fopen((char*)file_a, "w");
  if (f_st == (FILE*)NULL) {
    fprintf(stdout, "Warning: state occupancy not available\n");
    return ISIP_FALSE;
  }
  
  for (int_4 i = 1; i < num_states_a; i++) {
    fprintf(f_st, "%ld %f\n", i, state_occ_a[i]);
  }
  
  // exit gracefully
  //
  fclose(f_st);
  f_st = (FILE*)NULL;
  return ISIP_TRUE;
}
