📄 ngrm_lm_0.cc
字号:
// file: ngrm_lm_0.cc//// isip include files//#include "ngram.h"#include "ngram_constants.h"// method: get_score_cc//// arguments:// int_4 num: (input) size of word array// Word** words: (input) pointers for words in list// // return: a float_4 score represented by the ngram//// this method returns the score represented by the ngram//float_4 Ngram::get_score_cc(int_4 num_a, Word** words_a) { // define temporary variables used in function // logical_1 flag = ISIP_TRUE; float_4 score = NGRAM_NODE_DEFAULT_SCORE; Ngram_node** ngnode = (Ngram_node**)NULL; // get the correct ngram node // for (int_4 i = 0; i < num_a; i++) { // find the successive nodes // ngram_lists_d[i]->get_node_cc(words_a[i], ngnode); // if any of these ngram word sequences do not exist // if (ngnode == (Ngram_node**)NULL) { // set flag and break // flag = ISIP_FALSE; break; } } // end for loop // get lm score if ngram exists // if (flag == ISIP_TRUE) { score = (*ngnode)->get_lmscore_cc(); } // else, use back-off to get ngram score // else if (num_a - 1 > 0) { // get the backoff score // score = get_backoff_cc(num_a - 1, words_a); // add the lm score of the current word for a shorter history list // score += get_score_cc(num_a - 1, words_a + 1); } // otherwise this word sequence is invalid // else { fprintf(stdout, "The word sequence :: "); for (int_4 i = 0; i < num_a; i++) { fprintf(stdout, "%s ", words_a[i]->get_name_cc()); } fprintf(stdout, ":: is not available in this language model\n"); } // return score and exit gracefully // return score;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -