33 int char_reco_cost,
LangModEdge *edge,
int col_idx) {
36 lang_mod_edge_ = edge;
38 parent_node_ = parent_node;
39 char_reco_cost_ = char_reco_cost;
45 best_path_reco_cost_ = (parent_node_ ==
NULL) ? 0 :
49 best_path_len_ = (parent_node_ ==
NULL) ?
56 mean_char_reco_cost_ =
static_cast<int>(
57 (best_path_reco_cost_ + char_reco_cost_) /
58 static_cast<double>(best_path_len_));
61 int lm_cost =
LangModCost(lang_mod_edge_, parent_node_);
65 (best_path_reco_cost_ + char_reco_cost_) /
66 static_cast<double>(best_path_len_)
71 if (lang_mod_edge_ !=
NULL) {
72 delete lang_mod_edge_;
79 if (lang_mod_edge_ ==
NULL) {
80 if (new_edge !=
NULL) {
93 int new_best_path_reco_cost;
95 int new_best_path_len;
97 new_best_path_reco_cost = (new_parent ==
NULL) ?
104 int new_lm_cost =
LangModCost(new_edge, new_parent);
107 (new_best_path_reco_cost + new_reco_cost) /
108 static_cast<double>(new_best_path_len)
112 if (best_cost_ > new_cost) {
113 parent_node_ = new_parent;
114 char_reco_cost_ = new_reco_cost;
115 best_path_reco_cost_ = new_best_path_reco_cost;
116 best_path_len_ = new_best_path_len;
117 mean_char_reco_cost_ =
static_cast<int>(
118 (best_path_reco_cost_ + char_reco_cost_) /
119 static_cast<double>(best_path_len_));
121 (best_path_reco_cost_ + char_reco_cost_) /
122 static_cast<double>(best_path_len_)
135 while (node !=
NULL) {
136 if (node->str_ !=
NULL) {
146 node = node->parent_node_;
150 if (char_ptr ==
NULL) {
157 char_ptr[ch_idx--] = 0;
159 while (node !=
NULL) {
161 while (str_len > 0) {
162 char_ptr[ch_idx--] = node->str_[--str_len];
168 char_ptr[ch_idx--] = (
char_32)
' ';
171 node = node->parent_node_;
179 if (node1 !=
NULL && node2 !=
NULL &&
180 node1->best_path_len_ != node2->best_path_len_) {
185 while (node1 !=
NULL && node2 !=
NULL) {
186 if (node1->str_ != node2->str_) {
195 node1 = node1->parent_node_;
196 node2 = node2->parent_node_;
199 return ((node1 ==
NULL && node2 ==
NULL) ||
212 bool is_root = ((current_lm_edge !=
NULL && current_lm_edge->
IsRoot()) ||
213 parent_node ==
NULL);
216 lm_cost += (current_lm_edge ==
NULL ? 0 : current_lm_edge->
PathCost());
220 if (parent_node ==
NULL) {
230 return static_cast<int>(lm_cost /
static_cast<double>(node_cnt));
virtual bool IsIdentical(LangModEdge *edge) const =0
virtual bool IsRoot() const =0
static bool IdenticalPath(SearchNode *node1, SearchNode *node2)
bool UpdateParent(SearchNode *new_parent, int new_reco_cost, LangModEdge *new_edge)
virtual const char_32 * EdgeString() const =0
TuningParams * Params() const
static int StrLen(const char_32 *str)
LangModEdge * LangModelEdge()
SearchNode * ParentNode()
virtual int PathCost() const =0
SearchNode(CubeRecoContext *cntxt, SearchNode *parent_node, int char_reco_cost, LangModEdge *edge, int col_idx)