#include <search_node.h>
Definition at line 35 of file search_node.h.
◆ SearchNode()
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
◆ ~SearchNode()
tesseract::SearchNode::~SearchNode |
( |
| ) |
|
Definition at line 70 of file search_node.cpp.
71 if (lang_mod_edge_ != NULL) {
72 delete lang_mod_edge_;
◆ BestCost()
int tesseract::SearchNode::BestCost |
( |
| ) |
|
|
inline |
◆ BestPathLength()
int tesseract::SearchNode::BestPathLength |
( |
| ) |
|
|
inline |
◆ BestPathRecoCost()
int tesseract::SearchNode::BestPathRecoCost |
( |
| ) |
|
|
inline |
Definition at line 58 of file search_node.h.
58 {
return best_path_reco_cost_; }
◆ BestRecoCost()
int tesseract::SearchNode::BestRecoCost |
( |
| ) |
|
|
inline |
Definition at line 66 of file search_node.h.
66 {
return mean_char_reco_cost_ ; }
◆ CharRecoCost()
int tesseract::SearchNode::CharRecoCost |
( |
| ) |
|
|
inline |
Definition at line 55 of file search_node.h.
55 {
return char_reco_cost_; }
◆ ColIdx()
int tesseract::SearchNode::ColIdx |
( |
| ) |
|
|
inline |
◆ IdenticalPath()
Definition at line 175 of file search_node.cpp.
176 if (node1 != NULL && node2 != NULL &&
177 node1->best_path_len_ != node2->best_path_len_) {
182 while (node1 != NULL && node2 != NULL) {
183 if (node1->str_ != node2->str_) {
188 if (node1->LangModelEdge()->IsRoot() || node2->LangModelEdge()->IsRoot()) {
192 node1 = node1->parent_node_;
193 node2 = node2->parent_node_;
196 return ((node1 == NULL && node2 == NULL) ||
197 (node1 != NULL && node1->LangModelEdge()->IsRoot() &&
198 node2 != NULL && node2->LangModelEdge()->IsRoot()));
◆ LangModCost()
int tesseract::SearchNode::LangModCost |
( |
| ) |
|
|
inline |
◆ LangModelEdge()
◆ NodeString()
const char_32* tesseract::SearchNode::NodeString |
( |
| ) |
|
|
inline |
◆ ParentNode()
◆ PathString()
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_;
154 char_ptr[ch_idx--] = 0;
156 while (node != NULL) {
158 while (str_len > 0) {
159 char_ptr[ch_idx--] = node->str_[--str_len];
163 LangModEdge *lm_edge = node->LangModelEdge();
164 if (lm_edge != NULL && lm_edge->IsRoot() && node->ParentNode() != NULL) {
165 char_ptr[ch_idx--] = (
char_32)
' ';
168 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)
◆ SearchNodeComparer()
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)
◆ SetString()
void tesseract::SearchNode::SetString |
( |
char_32 * |
str | ) |
|
|
inline |
◆ UpdateParent()
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) {
86 if (new_edge == NULL || !lang_mod_edge_->
IsIdentical(new_edge) ||
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_)
static bool IdenticalPath(SearchNode *node1, SearchNode *node2)
virtual bool IsIdentical(LangModEdge *edge) const =0
TuningParams * Params() const
The documentation for this class was generated from the following files: