23 #ifndef TESSERACT_CLASSIFY_SHAPETABLE_H_ 24 #define TESSERACT_CLASSIFY_SHAPETABLE_H_ 26 #include "bitvector.h" 28 #include "genericheap.h" 29 #include "genericvector.h" 30 #include "intmatcher.h" 50 tprintf(
"Unichar-id=%d, rating=%g, adapted=%d, config=%d, misses=%d," 95 : shape_id(0),
rating(0.0f), raw(0.0f), font(0.0f),
96 joined(false), broken(false) {}
98 : shape_id(s),
rating(r), raw(1.0f), font(0.0f),
99 joined(false), broken(false) {}
141 : result(rating), level(level0) {}
147 return level > other.
level;
164 font_ids.push_back(font_id);
173 static int SortByUnicharId(
const void* v1,
const void* v2);
195 return destination_index_;
198 destination_index_ = index;
201 return unichars_.size();
206 return unichars_[index];
216 void AddShape(
const Shape& other);
218 bool ContainsUnicharAndFont(
int unichar_id,
int font_id)
const;
220 bool ContainsUnichar(
int unichar_id)
const;
222 bool ContainsFont(
int font_id)
const;
226 uint32_t properties)
const;
229 bool ContainsMultipleFontProperties(
const FontInfoTable& font_table)
const;
232 bool operator==(
const Shape& other)
const;
234 bool IsSubsetOf(
const Shape& other)
const;
238 bool IsEqualUnichars(
Shape* other);
276 return shape_table_.size();
283 int NumFonts()
const;
287 unicharset_ = &unicharset;
293 STRING DebugStr(
int shape_id)
const;
295 STRING SummaryStr()
const;
302 int AddShape(
const Shape& other);
304 void DeleteShape(
int shape_id);
307 void AddToShape(
int shape_id,
int unichar_id,
int font_id);
309 void AddShapeToShape(
int shape_id,
const Shape& other);
314 int FindShape(
int unichar_id,
int font_id)
const;
316 void GetFirstUnicharAndFont(
int shape_id,
317 int* unichar_id,
int* font_id)
const;
321 return *shape_table_[shape_id];
324 return shape_table_[shape_id];
329 int BuildFromShape(
const Shape& shape,
const ShapeTable& master_shapes);
332 bool AlreadyMerged(
int shape_id1,
int shape_id2)
const;
334 bool AnyMultipleUnichars()
const;
336 int MaxNumUnichars()
const;
339 void ForceFontMerges(
int start,
int end);
341 int MasterUnicharCount(
int shape_id)
const;
343 int MasterFontCount(
int shape_id)
const;
345 int MergedUnicharCount(
int shape_id1,
int shape_id2)
const;
347 void MergeShapes(
int shape_id1,
int shape_id2);
349 void SwapShapes(
int shape_id1,
int shape_id2);
354 void AppendMasterShapes(
const ShapeTable& other,
357 int NumMasterShapes()
const;
361 int MasterDestinationIndex(
int shape_id)
const;
364 bool SubsetUnichar(
int shape_id1,
int shape_id2)
const;
366 bool MergeSubsetUnichar(
int merge_id1,
int merge_id2,
int shape_id)
const;
368 bool EqualUnichars(
int shape_id1,
int shape_id2)
const;
369 bool MergeEqualUnichars(
int merge_id1,
int merge_id2,
int shape_id)
const;
371 bool CommonUnichars(
int shape_id1,
int shape_id2)
const;
373 bool CommonFont(
int shape_id1,
int shape_id2)
const;
382 void AddShapeToResults(
const ShapeRating& shape_rating,
389 int AddUnicharToResults(
int unichar_id,
float rating,
404 #endif // TESSERACT_CLASSIFY_SHAPETABLE_H_ Definition: genericheap.h:58
UnicharAndFonts(int uni_id, int font_id)
Definition: shapetable.h:163
Definition: shapetable.h:138
const UnicharAndFonts & operator[](int index) const
Definition: shapetable.h:205
Definition: shapetable.h:185
float font
Definition: shapetable.h:129
int num_fonts_
Definition: shapetable.h:399
GenericVector< UnicharAndFonts > unichars_
Definition: shapetable.h:252
static int SortDescendingRating(const void *t1, const void *t2)
Definition: shapetable.h:56
UnicharRating()
Definition: shapetable.h:42
ShapeQueueEntry(const ShapeRating &rating, int level0)
Definition: shapetable.h:140
int level
Definition: shapetable.h:154
Definition: unicharset.h:146
Definition: shapetable.h:160
Shape()
Definition: shapetable.h:187
static int SortDescendingRating(const void *t1, const void *t2)
Definition: shapetable.h:102
Definition: serialis.h:77
const UNICHARSET & unicharset() const
Definition: shapetable.h:278
Definition: baseapi.cpp:94
int destination_index() const
Definition: shapetable.h:194
UNICHAR_ID unichar_id
Definition: shapetable.h:75
ShapeRating(int s, float r)
Definition: shapetable.h:97
static int FirstResultWithUnichar(const GenericVector< UnicharRating > &results, UNICHAR_ID unichar_id)
Definition: shapetable.cpp:58
bool operator<(const ShapeQueueEntry &other) const
Definition: shapetable.h:144
bool broken
Definition: shapetable.h:133
UnicharRating(int u, float r)
Definition: shapetable.h:45
void SetUnicharId(int index, int unichar_id)
Definition: shapetable.h:209
Definition: shapetable.h:93
PointerVector< Shape > shape_table_
Definition: shapetable.h:396
UnicharAndFonts()
Definition: shapetable.h:161
float rating
Definition: shapetable.h:125
int size() const
Definition: shapetable.h:200
int NumShapes() const
Definition: shapetable.h:275
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:59
const UNICHARSET * unicharset_
Definition: shapetable.h:394
GenericVector< int32_t > font_ids
Definition: shapetable.h:175
bool adapted
Definition: shapetable.h:80
Definition: shapetable.h:262
int shape_id
Definition: shapetable.h:122
void set_unicharset(const UNICHARSET &unicharset)
Definition: shapetable.h:286
ShapeRating result
Definition: shapetable.h:152
ShapeRating()
Definition: shapetable.h:94
Definition: fontinfo.h:146
Definition: genericvector.h:457
const Shape & GetShape(int shape_id) const
Definition: shapetable.h:320
float raw
Definition: shapetable.h:127
GenericVector< ScoredFont > fonts
Definition: shapetable.h:88
bool joined
Definition: shapetable.h:131
void Print() const
Definition: shapetable.h:49
int destination_index_
Definition: shapetable.h:249
int32_t unichar_id
Definition: shapetable.h:176
Shape * MutableShape(int shape_id)
Definition: shapetable.h:323
float rating
Definition: shapetable.h:78
ShapeQueueEntry()
Definition: shapetable.h:139
void set_destination_index(int index)
Definition: shapetable.h:197
bool unichars_sorted_
Definition: shapetable.h:246
bool DeSerialize(FILE *fp, char *data, size_t n)
Definition: serialis.cpp:27
Definition: shapetable.h:41
uint8_t config
Definition: shapetable.h:82
uint16_t feature_misses
Definition: shapetable.h:84