// file: latp_path_0.cc
//

// isip include files
//
#include "lattice_path.h"
#include "lattice_path_constants.h"

// method: project_cc
//
// arguments:
//  Lattice_path* lpath: (input) the lattice path to project
//  Lattice_node* latn: (input) the lattice node in the new path
//  int_4 type: (input) type of the new path
//
// return: a logical_1 indicating status
//
// this method projects the input path to the current one and updates
// appropriate parameters
//
logical_1 Lattice_path::project_cc(Lattice_path* lpath_a,
				   Lattice_node* latn_a, int_4 type_a) {

  // update parameters of the new path
  //
  word_pos_d = lpath_a->word_pos_d;
  path_type_d = type_a;
  score_d = lpath_a->score_d;
  curr_d = latn_a;
  prev_d = lpath_a;

  // update the position and score depending on the type
  // if this is of type correct
  //
  if (path_type_d == LATTICE_PATH_CORRECT) {
    word_pos_d++;
    score_d += LATTICE_PATH_CORRECT_PENALTY;
  }
  
  // else if this is of type substitution
  //
  else if (path_type_d == LATTICE_PATH_SUBSTITUTION) {
    word_pos_d++;
    score_d += LATTICE_PATH_SUBSTITUTION_PENALTY;
  }
  
  // else if this is of type insertion
  //
  else if (path_type_d == LATTICE_PATH_INSERTION) {
    score_d += LATTICE_PATH_INSERTION_PENALTY;
  }
  
  // else if this is of type deletion
  //
  else if (path_type_d == LATTICE_PATH_DELETION) {
    word_pos_d++;
    score_d += LATTICE_PATH_DELETION_PENALTY;
  }
  
  // else if this is of type substitution
  //
  else if (path_type_d == LATTICE_PATH_SKIP) {
    score_d += LATTICE_PATH_SKIP_PENALTY;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
