📄 tr_lxt_tree_0.cc
字号:
// file: tr_lxt_tree_0.cc//// isip include files//#include "train_lex_tree.h"#include "train_lex_tree_constants.h"// method: build_tree_cc//// arguments:// Train_Lattice_node* lat_node : (input) the lattice node for the word to add// float_8 score : (input) the word transition score for this word//// return: a logical_1 to indicate success//// this method loops over all pronunciations of the input word, for// each pronunciation it checks phone-by-phone if the current phone is// already on the correct branch of the tree and inserts the word and// score in the corresponding node//logical_1 Train_Lex_tree::build_tree_cc(Train_Lattice_node* lat_node_a, float_8 score_a) { // phone / word parameters // int_4 phone = (int_4)-1; int_4 num_prons = (int_4)0; int_4* num_ph = (int_4*)0; int_4** phlist = (int_4**)NULL; // get the word data // Train_Word* word = lat_node_a->get_word_cc(); num_prons = word->get_num_prons_cc(); phlist = word->get_phone_list_cc(); num_ph = word->get_num_phones_cc(); // dummy lexical nodes // Train_Lex_node* curr_node = (Train_Lex_node*)NULL; Train_Lex_node* next_node = (Train_Lex_node*)NULL; Train_Lex_node* stop_node = (Train_Lex_node*)NULL; Train_Lex_node* st_node = (Train_Lex_node*)NULL; // memory manager // Train_Memory_manager* manager = Train_Link_list::get_manager_cc(); // set the tree pointer in the head node // if (head_d->get_tree_cc() == (void_p)NULL) { head_d->set_tree_cc((void_p)this); } // loop over all the pronunciations for this word // for (int_4 i = 0; i < num_prons; i++) { // set the next node as current // stop_node = (Train_Lex_node*)NULL; next_node = head_d; // loop over all phones in this pronunciations // for (int_4 j = 0; j < num_ph[i]; j++) { // set the current node // curr_node = next_node; // the jth phone of this ith pronunciation // phone = phlist[i][j]; // get the node in the tree that contains this phone // next_node = curr_node->make_node_cc(phone); if (next_node->get_tree_cc() == (void_p)NULL) { next_node->set_tree_cc(this); } // add the current word to the list at this node and adjust LM // score // next_node->add_word_cc(lat_node_a, score_a); } // add the stop node at the end of word // st_node = next_node->get_node_cc(TRAIN_LXN_STOP_PHONE); if (st_node != (Train_Lex_node*)NULL) { st_node->add_word_cc(lat_node_a, score_a); st_node = (Train_Lex_node*)NULL; } else { // create a stop node // stop_node = manager->new_lex_cc(); stop_node->set_phone_cc(TRAIN_LXN_STOP_PHONE); stop_node->set_tree_cc((void_p)this); stop_node->add_word_cc(lat_node_a, score_a); // insert it in the appropriate place // next_node->add_child_cc(stop_node); } // if this is the end of word with an sp phone add the word-stop // as the child of the current node as well // if (phlist[i][num_ph[i] - 1] == TRAIN_LXN_SP_PHONE) { st_node = curr_node->get_node_cc(TRAIN_LXN_STOP_PHONE); if (st_node != (Train_Lex_node*)NULL) { st_node->add_word_cc(lat_node_a, score_a); st_node = (Train_Lex_node*)NULL; } else { curr_node->add_child_cc(stop_node); } } } // end loop over all pronunciations // exit gracefully // return ISIP_TRUE; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -