// file: bw_check_phone.cc
//

// system include files
//
#include <string.h>

// isip include files
//
#include "bw_train.h"
#include "bw_train_constants.h"

// method: check_phone_cc
//
// arguments:
//  char_1* phone : (input) the current monophone
//  char_1** monophones : (input) list of monophones
//  int_4 num_mono : (input) the number of monophones
//
// return: a logical flag to indicate success
//
// this method checks whether the monophone is a valid monophone
//

logical_1 check_phone_cc(char_1* phone_a, char_1** monophones_a,
			 int_4 num_mono_a) {

  // local variables
  //
  // set a flag to check whether a phone exists
  //
  logical_1 phone_exists_flag = ISIP_FALSE;

  // check whether the current phone exists in the list of monophones
  //
  for(int_4 i = 0; i < num_mono_a; i++) {
    if (strcmp((char*)phone_a, (char*)monophones_a[i]) == 0) {
      phone_exists_flag = ISIP_TRUE;
      break;
    }
  }

  // check if monophone exists
  // if not exit ungracefully
  //
  if(phone_exists_flag == ISIP_FALSE) {
    fprintf(stdout, "monophone '%s' not found\n",phone_a);
    exit(ISIP_PROTO_ERROR);
  }

  // exit gracefully
  //
  return(ISIP_TRUE);
}


