41 if (pain_points_heaps_[h].empty()) {
44 *priority = pain_points_heaps_[h].
PeekTop().
key();
46 pain_points_heaps_[h].
Pop(
nullptr);
55 for (
int col = 0; col < ratings->
dimension(); ++col) {
57 for (
int row = col + 1; row < row_end; ++row) {
111 float priority = ol_dif > 0 ? (vse->
ratings_sum - rat_subtr) / ol_dif : 0.0;
113 max_char_wh_ratio_, word_res);
114 }
else if (debug_level_ > 3) {
115 tprintf(
"NO pain point (Classified) for col=%d row=%d type=%s\n", pain_coord.
col,
117 BLOB_CHOICE_IT b_it(word_res->
ratings->
get(pain_coord.
col, pain_coord.
row));
118 for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
124 curr_vse = parent_vse;
125 curr_b = curr_vse->
curr_b;
133 for (
auto &&danger : fixpt) {
135 if (danger.dangerous) {
143 float special_priority,
bool ok_to_extend,
144 float max_char_wh_ratio,
WERD_RES *word_res) {
150 if (debug_level_ > 3) {
151 tprintf(
"Generating pain point for col=%d row=%d type=%s\n", col, row,
152 LMPainPointsTypeName[pp_type]);
157 debug_level_, &associate_stats);
166 word_res, debug_level_, &associate_stats);
170 if (debug_level_ > 3) {
171 tprintf(
"Discarded pain point with a bad shape\n");
177 if (pain_points_heaps_[pp_type].size() < max_heap_size_) {
181 priority = special_priority;
183 priority = associate_stats.
gap_sum;
186 pain_points_heaps_[pp_type].
Push(&pain_point);
188 tprintf(
"Added pain point with priority %g\n", priority);
193 tprintf(
"Pain points heap is full\n");
204 for (
auto &pain_points_heap : pain_points_heaps_) {
205 std::vector<MatrixCoordPair> &heap = pain_points_heap.heap();
206 for (
auto &&entry : heap) {
207 entry.data().MapForSplit(index);
void tprintf(const char *format,...)
std::vector< DANGERR_INFO > DANGERR
bool Classified(int col, int row, int wildcard_id) const
bool Valid(const MATRIX &m) const
const MATRIX_COORD & matrix_cell()
const Pair & PeekTop() const
UNICHAR_ID WildcardID() const
bool bad_fixed_pitch_wh_ratio
bool bad_fixed_pitch_right_gap
static float ComputeOutlineLength(float rating_cert_scale, const BLOB_CHOICE &b)
static void ComputeStats(int col, int row, const AssociateStats *parent_stats, int parent_path_length, bool fixed_pitch, float max_char_wh_ratio, WERD_RES *word_res, bool debug, AssociateStats *stats)
bool GeneratePainPoint(int col, int row, LMPainPointsType pp_type, float special_priority, bool ok_to_extend, float max_char_wh_ratio, WERD_RES *word_res)
void RemapForSplit(int index)
void GenerateInitial(WERD_RES *word_res)
void GenerateFromPath(float rating_cert_scale, ViterbiStateEntry *vse, WERD_RES *word_res)
static const float kLooseMaxCharWhRatio
static const float kDefaultPainPointPriorityAdjustment
void GenerateFromAmbigs(const DANGERR &fixpt, ViterbiStateEntry *vse, WERD_RES *word_res)
LMPainPointsType Deque(MATRIX_COORD *pp, float *priority)
float outline_length
length of the outline so far
BLOB_CHOICE * curr_b
Pointers to BLOB_CHOICE and parent ViterbiStateEntry (not owned by this).
ViterbiStateEntry * parent_vse
float ratings_sum
sum of ratings of character on the path