📄 ngrm_lm_3.cc
字号:
// file: ngrm_lm_3.cc//// system include files//#include <string.h>// isip include files//#include "ngram.h"#include "ngram_constants.h"// method: get_backoff_cc//// arguments:// int_4 num: (input) size of word history// Word** words_a: (input) pointers for words in history list// // return: a float_4 containing the backoff score for the given words//// this method checks if an ngram of the specified size exists// corresponding to the given word list and finds the ngram node and// returns the back-off score. if the node doesn't exist, it returns// 0.//float_4 Ngram::get_backoff_cc(int_4 num_a, Word** words_a) { // define temporary variables used in function // float_4 flag = ISIP_TRUE; float_4 score = (float_4)0; Ngram_node** ngnode = (Ngram_node**)NULL; // first try to see if this is an existing ngram // 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 backoff score if ngram exists // if (flag == ISIP_TRUE) { score = (*ngnode)->get_backoff_cc(); } // return the score and exit gracefully // return score;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -