21 #ifndef THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_ 22 #define THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_ 104 bool word_start,
bool end,
bool dup,
float cert,
float s,
129 memcpy(
this, &src,
sizeof(src));
135 void Print(
int null_char,
const UNICHARSET& unicharset,
int depth)
const;
180 bool simple_text,
Dict* dict);
184 void Decode(
const NetworkIO& output,
double dict_ratio,
double cert_offset,
185 double worst_dict_cert,
const UNICHARSET* charset);
187 double cert_offset,
double worst_dict_cert,
195 void ExtractBestPathAsUnicharIds(
bool debug,
const UNICHARSET* unicharset,
202 void ExtractBestPathAsWords(
const TBOX& line_box,
float scale_factor,
207 void DebugBeams(
const UNICHARSET& unicharset)
const;
218 static const int kNumBeams = 2 *
NC_COUNT * kNumLengths;
225 return index / (kNumLengths *
NC_COUNT) > 0;
229 return (is_dawg *
NC_COUNT + cont) * kNumLengths + length;
239 for (
int i = 0; i < kNumBeams; ++i) {
243 for (
int i = 0; i <
NC_COUNT; ++i) {
244 best_initial_dawgs_[i] = empty;
257 RecodeHeap beams_[kNumBeams];
268 void DebugBeamPos(
const UNICHARSET& unicharset,
const RecodeHeap& heap)
const;
272 static void ExtractPathAsUnicharIds(
279 WERD_RES* InitializeWord(
bool leading_space,
const TBOX& line_box,
280 int word_start,
int word_end,
float space_certainty,
287 void ComputeTopN(
const float* outputs,
int num_outputs,
int top_n);
292 void DecodeStep(
const float* outputs,
int t,
double dict_ratio,
293 double cert_offset,
double worst_dict_cert,
300 void ContinueContext(
const RecodeNode*
prev,
int index,
const float* outputs,
302 double cert_offset,
double worst_dict_cert,
306 float worst_dict_cert,
float dict_ratio,
bool use_dawgs,
311 void ContinueDawg(
int code,
int unichar_id,
float cert,
NodeContinuation cont,
316 bool start,
bool end,
float cert,
322 void PushDupOrNoDawgIfBetter(
int length,
bool dup,
int code,
int unichar_id,
323 float cert,
float worst_dict_cert,
324 float dict_ratio,
bool use_dawgs,
329 void PushHeapIfBetter(
int max_size,
int code,
int unichar_id,
330 PermuterType permuter,
bool dawg_start,
bool word_start,
331 bool end,
bool dup,
float cert,
const RecodeNode* prev,
335 void PushHeapIfBetter(
int max_size,
RecodeNode* node, RecodeHeap* heap);
338 bool UpdateHeapIfMatched(
RecodeNode* new_node, RecodeHeap* heap);
355 void DebugUnicharPath(
const UNICHARSET* unicharset,
382 bool space_delimited_;
385 bool is_simple_text_;
392 #endif // THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_
static bool IsDawgFromBeamsIndex(int index)
RecodeNode(int c, int uni_id, PermuterType perm, bool dawg_start, bool word_start, bool end, bool dup, float cert, float s, const RecodeNode *p, DawgPositionVector *d, uinT64 hash)
static const float kMinCertainty
static const int kMaxCodeLen
void Print(int null_char, const UNICHARSET &unicharset, int depth) const
static int LengthFromBeamsIndex(int index)
GenericHeap< RecodePair > RecodeHeap
RecodeNode(RecodeNode &src)
RecodeNode & operator=(RecodeNode &src)
static NodeContinuation ContinuationFromBeamsIndex(int index)
static int BeamIndex(bool is_dawg, NodeContinuation cont, int length)
KDPairInc< double, RecodeNode > RecodePair
DawgPositionVector * dawgs