20 #ifndef THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_ 21 #define THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_ 107 bool word_start,
bool end,
bool dup,
float cert,
float s,
132 memcpy(
this, &src,
sizeof(src));
138 void Print(
int null_char,
const UNICHARSET& unicharset,
int depth)
const;
183 bool simple_text,
Dict* dict);
187 void Decode(
const NetworkIO& output,
double dict_ratio,
double cert_offset,
188 double worst_dict_cert,
const UNICHARSET* charset,
189 int lstm_choice_mode = 0);
191 double cert_offset,
double worst_dict_cert,
199 void ExtractBestPathAsUnicharIds(
bool debug,
const UNICHARSET* unicharset,
206 void ExtractBestPathAsWords(
const TBOX& line_box,
float scale_factor,
209 int lstm_choice_mode = 0);
212 void DebugBeams(
const UNICHARSET& unicharset)
const;
216 std::vector< std::vector<std::pair<const char*, float>>>
timesteps;
227 static const int kNumBeams = 2 *
NC_COUNT * kNumLengths;
234 return index / (kNumLengths *
NC_COUNT) > 0;
238 return (is_dawg *
NC_COUNT + cont) * kNumLengths + length;
248 for (
auto & beam : beams_) {
252 for (
auto & best_initial_dawg : best_initial_dawgs_) {
253 best_initial_dawg = empty;
281 static void ExtractPathAsUnicharIds(
285 std::deque<std::tuple<int, int>>* best_choices =
nullptr);
289 WERD_RES* InitializeWord(
bool leading_space,
const TBOX& line_box,
290 int word_start,
int word_end,
float space_certainty,
297 void ComputeTopN(
const float* outputs,
int num_outputs,
int top_n);
302 void DecodeStep(
const float* outputs,
int t,
double dict_ratio,
303 double cert_offset,
double worst_dict_cert,
304 const UNICHARSET* charset,
bool debug =
false);
307 void SaveMostCertainChoices(
const float* outputs,
int num_outputs,
const UNICHARSET* charset,
int xCoord);
313 void ContinueContext(
const RecodeNode*
prev,
int index,
const float* outputs,
315 double dict_ratio,
double cert_offset,
316 double worst_dict_cert, RecodeBeam* step);
319 float worst_dict_cert,
float dict_ratio,
bool use_dawgs,
324 void ContinueDawg(
int code,
int unichar_id,
float cert,
NodeContinuation cont,
329 bool start,
bool end,
float cert,
335 void PushDupOrNoDawgIfBetter(
int length,
bool dup,
int code,
int unichar_id,
336 float cert,
float worst_dict_cert,
337 float dict_ratio,
bool use_dawgs,
342 void PushHeapIfBetter(
int max_size,
int code,
int unichar_id,
343 PermuterType permuter,
bool dawg_start,
bool word_start,
344 bool end,
bool dup,
float cert,
const RecodeNode* prev,
353 uint64_t ComputeCodeHash(
int code,
bool dup,
const RecodeNode* prev)
const;
368 void DebugUnicharPath(
const UNICHARSET* unicharset,
395 bool space_delimited_;
398 bool is_simple_text_;
405 #endif // THIRD_PARTY_TESSERACT_LSTM_RECODEBEAM_H_
static NodeContinuation ContinuationFromBeamsIndex(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_t hash)
static int LengthFromBeamsIndex(int index)
static const int kMaxCodeLen
static const float kMinCertainty
std::vector< std::vector< std::pair< const char *, float > > > timesteps
DawgPositionVector * dawgs
RecodeNode(RecodeNode &src)
static int BeamIndex(bool is_dawg, NodeContinuation cont, int length)
RecodeNode & operator=(RecodeNode &src)
void Print(int null_char, const UNICHARSET &unicharset, int depth) const
static bool IsDawgFromBeamsIndex(int index)