// file: lxn_node_3.cc
//

// isip include files
//
#include "lex_node.h"
#include "lex_node_constants.h"

// method: add_word_cc
//
// arguments:
//  void_p word : (input) the node of the word to be added
//  float_4 score: (input) lm score of this word
//
// return: a logical_1 indicating success
//
// this method adds the input word to the current word list
//
logical_1 Lex_node::add_word_cc(void_p word_a, float_4 score_a) {
  
  // check if the word list exists
  //
  if (words_d == (Link_list*)NULL) {
    words_d = new Link_list();
  }
  
  // check if this word is already here
  //
  for (Link_node* nd = words_d->get_head_cc(); nd != (Link_node*)NULL;
       nd = nd->get_next_cc()) {

    // return if the item is already present
    //
    if (nd->get_item_cc() == word_a) {
      return ISIP_TRUE;
    }
  }

  // add the word to the list
  //
  words_d->insert_cc(word_a);

  // update score
  //
  if (score_d < score_a) {
    score_d = score_a;
  }
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
