#include <search_node.h>
Definition at line 35 of file search_node.h.
Definition at line 32 of file search_node.cpp.
36 lang_mod_edge_ = edge;
38 parent_node_ = parent_node;
39 char_reco_cost_ = char_reco_cost;
42 str_ = (edge ==
NULL ?
NULL : edge->EdgeString());
45 best_path_reco_cost_ = (parent_node_ ==
NULL) ? 0 :
49 best_path_len_ = (parent_node_ ==
NULL) ?
51 if (edge !=
NULL && edge->IsRoot() && 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_)
TuningParams * Params() const
tesseract::SearchNode::~SearchNode |
( |
| ) |
|
Definition at line 70 of file search_node.cpp.
71 if (lang_mod_edge_ !=
NULL) {
72 delete lang_mod_edge_;
int tesseract::SearchNode::BestCost |
( |
| ) |
|
|
inline |
int tesseract::SearchNode::BestPathLength |
( |
| ) |
|
|
inline |
int tesseract::SearchNode::BestPathRecoCost |
( |
| ) |
|
|
inline |
Definition at line 58 of file search_node.h.
58 {
return best_path_reco_cost_; }
int tesseract::SearchNode::BestRecoCost |
( |
| ) |
|
|
inline |
Definition at line 66 of file search_node.h.
66 {
return mean_char_reco_cost_ ; }
int tesseract::SearchNode::CharRecoCost |
( |
| ) |
|
|
inline |
Definition at line 55 of file search_node.h.
55 {
return char_reco_cost_; }
int tesseract::SearchNode::ColIdx |
( |
| ) |
|
|
inline |
Definition at line 178 of file search_node.cpp.
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_) {
191 if (node1->LangModelEdge()->IsRoot() || node2->LangModelEdge()->IsRoot()) {
195 node1 = node1->parent_node_;
196 node2 = node2->parent_node_;
199 return ((node1 ==
NULL && node2 ==
NULL) ||
200 (node1 !=
NULL && node1->LangModelEdge()->IsRoot() &&
201 node2 !=
NULL && node2->LangModelEdge()->IsRoot()));
int tesseract::SearchNode::LangModCost |
( |
| ) |
|
|
inline |
const char_32* tesseract::SearchNode::NodeString |
( |
| ) |
|
|
inline |
char_32 * tesseract::SearchNode::PathString |
( |
| ) |
|
Definition at line 129 of file search_node.cpp.
135 while (node !=
NULL) {
136 if (node->str_ !=
NULL) {
141 LangModEdge *lm_edge = node->LangModelEdge();
142 if (lm_edge !=
NULL && lm_edge->IsRoot() && node->ParentNode() !=
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];
166 LangModEdge *lm_edge = node->LangModelEdge();
167 if (lm_edge !=
NULL && lm_edge->IsRoot() && node->ParentNode() !=
NULL) {
168 char_ptr[ch_idx--] = (
char_32)
' ';
171 node = node->parent_node_;
static int StrLen(const char_32 *str)
SearchNode(CubeRecoContext *cntxt, SearchNode *parent_node, int char_reco_cost, LangModEdge *edge, int col_idx)
static int tesseract::SearchNode::SearchNodeComparer |
( |
const void * |
node1, |
|
|
const void * |
node2 |
|
) |
| |
|
inlinestatic |
Definition at line 75 of file search_node.h.
76 return (*(reinterpret_cast<SearchNode * const *>(node1)))->best_cost_ -
77 (*(
reinterpret_cast<SearchNode *
const *
>(node2)))->best_cost_;
SearchNode(CubeRecoContext *cntxt, SearchNode *parent_node, int char_reco_cost, LangModEdge *edge, int col_idx)
void tesseract::SearchNode::SetString |
( |
char_32 * |
str | ) |
|
|
inline |
bool tesseract::SearchNode::UpdateParent |
( |
SearchNode * |
new_parent, |
|
|
int |
new_reco_cost, |
|
|
LangModEdge * |
new_edge |
|
) |
| |
Definition at line 77 of file search_node.cpp.
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) ?
98 0 : new_parent->BestPathRecoCost() + new_parent->CharRecoCost();
101 (new_parent ==
NULL) ? 1 : new_parent->BestPathLength() + 1;
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_)
virtual bool IsIdentical(LangModEdge *edge) const =0
static bool IdenticalPath(SearchNode *node1, SearchNode *node2)
TuningParams * Params() const
The documentation for this class was generated from the following files: