102 fprintf(stderr,
"Cube ERROR (BeamSearch::Search): could not construct " 111 seg_pt_cnt_ = srch_obj->SegPtCnt();
112 if (seg_pt_cnt_ < 0) {
115 col_cnt_ = seg_pt_cnt_ + 1;
118 if (seg_pt_cnt_ > 128) {
119 fprintf(stderr,
"Cube ERROR (BeamSearch::Search): segment point count is " 120 "suspiciously high; bailing out\n");
125 col_ =
new SearchColumn *[col_cnt_];
126 memset(col_, 0, col_cnt_ *
sizeof(*col_));
129 for (
int end_seg = 1; end_seg <= (seg_pt_cnt_ + 1); end_seg++) {
131 col_[end_seg - 1] =
new SearchColumn(end_seg - 1,
136 for (
int strt_seg = init_seg; strt_seg < end_seg; strt_seg++) {
137 int parent_nodes_cnt;
138 SearchNode **parent_nodes;
142 parent_nodes_cnt = 1;
146 parent_nodes_cnt = col_[strt_seg - 1]->
NodeCount();
147 parent_nodes = col_[strt_seg - 1]->
Nodes();
151 CharAltList *char_alt_list = srch_obj->RecognizeSegment(strt_seg - 1,
154 for (
int parent_idx = 0; parent_idx < parent_nodes_cnt; parent_idx++) {
156 SearchNode *parent_node = !parent_nodes ? NULL
157 : parent_nodes[parent_idx];
158 LangModEdge *lm_parent_edge = !parent_node ? lang_mod->Root()
162 int contig_cost = srch_obj->NoSpaceCost(strt_seg - 1, end_seg - 1);
166 int no_space_cost = 0;
167 if (!word_mode_ && strt_seg > 0) {
168 no_space_cost = srch_obj->NoSpaceCost(strt_seg - 1);
174 CreateChildren(col_[end_seg - 1], lang_mod, parent_node,
175 lm_parent_edge, char_alt_list,
176 contig_cost + no_space_cost);
180 if (!word_mode_ && strt_seg > 0) {
182 if (parent_node->LangModelEdge()->IsEOW()) {
184 int space_cost = srch_obj->SpaceCost(strt_seg - 1);
189 CreateChildren(col_[end_seg - 1], lang_mod, parent_node, NULL,
190 char_alt_list, contig_cost + space_cost);
198 col_[end_seg - 1]->
Prune();
204 WordAltList *alt_list = CreateWordAltList(srch_obj);
SearchNode ** Nodes() const
int MaxSegPerChar() const
LangModel * LangMod() const
LangModEdge * LangModelEdge()
TuningParams * Params() const