23 #ifndef TESSERACT_CLASSIFY_SHAPETABLE_H_ 24 #define TESSERACT_CLASSIFY_SHAPETABLE_H_ 50 tprintf(
"Unichar-id=%d, rating=%g, adapted=%d, config=%d, misses=%d," 197 return destination_index_;
200 destination_index_ = index;
203 return unichars_.size();
208 return unichars_[index];
212 unichars_[index].unichar_id = unichar_id;
248 bool unichars_sorted_;
251 int destination_index_;
272 bool Serialize(FILE* fp)
const;
275 bool DeSerialize(
bool swap, FILE* fp);
279 return shape_table_.size();
286 int NumFonts()
const;
290 unicharset_ = &unicharset;
296 STRING DebugStr(
int shape_id)
const;
298 STRING SummaryStr()
const;
302 int AddShape(
int unichar_id,
int font_id);
305 int AddShape(
const Shape& other);
307 void DeleteShape(
int shape_id);
310 void AddToShape(
int shape_id,
int unichar_id,
int font_id);
312 void AddShapeToShape(
int shape_id,
const Shape& other);
317 int FindShape(
int unichar_id,
int font_id)
const;
319 void GetFirstUnicharAndFont(
int shape_id,
320 int* unichar_id,
int* font_id)
const;
324 return *shape_table_[shape_id];
327 return shape_table_[shape_id];
332 int BuildFromShape(
const Shape& shape,
const ShapeTable& master_shapes);
335 bool AlreadyMerged(
int shape_id1,
int shape_id2)
const;
337 bool AnyMultipleUnichars()
const;
339 int MaxNumUnichars()
const;
342 void ForceFontMerges(
int start,
int end);
344 int MasterUnicharCount(
int shape_id)
const;
346 int MasterFontCount(
int shape_id)
const;
348 int MergedUnicharCount(
int shape_id1,
int shape_id2)
const;
350 void MergeShapes(
int shape_id1,
int shape_id2);
352 void SwapShapes(
int shape_id1,
int shape_id2);
357 void AppendMasterShapes(
const ShapeTable& other,
360 int NumMasterShapes()
const;
364 int MasterDestinationIndex(
int shape_id)
const;
367 bool SubsetUnichar(
int shape_id1,
int shape_id2)
const;
369 bool MergeSubsetUnichar(
int merge_id1,
int merge_id2,
int shape_id)
const;
371 bool EqualUnichars(
int shape_id1,
int shape_id2)
const;
372 bool MergeEqualUnichars(
int merge_id1,
int merge_id2,
int shape_id)
const;
374 bool CommonUnichars(
int shape_id1,
int shape_id2)
const;
376 bool CommonFont(
int shape_id1,
int shape_id2)
const;
385 void AddShapeToResults(
const ShapeRating& shape_rating,
392 int AddUnicharToResults(
int unichar_id,
float rating,
402 mutable int num_fonts_;
407 #endif // TESSERACT_CLASSIFY_SHAPETABLE_H_
static int FirstResultWithUnichar(const GenericVector< ShapeRating > &results, const ShapeTable &shape_table, UNICHAR_ID unichar_id)
static int FirstResultWithUnichar(const GenericVector< UnicharRating > &results, UNICHAR_ID unichar_id)
bool operator==(const Shape &other) const
bool operator<(const ShapeQueueEntry &other) const
UnicharRating(int u, float r)
bool ContainsFont(int font_id) const
bool ContainsFontProperties(const FontInfoTable &font_table, uinT32 properties) const
void AddShape(const Shape &other)
bool DeSerialize(bool swap, FILE *fp)
const UnicharAndFonts & operator[](int index) const
GenericVector< inT32 > font_ids
GenericVector< ScoredFont > fonts
bool ContainsUnichar(int unichar_id) const
GenericHeap< ShapeQueueEntry > ShapeQueue
bool Serialize(FILE *fp) const
ShapeRating(int s, float r)
const UNICHARSET & unicharset() const
static int SortDescendingRating(const void *t1, const void *t2)
void set_destination_index(int index)
bool IsEqualUnichars(Shape *other)
ShapeQueueEntry(const ShapeRating &rating, int level0)
bool Serialize(FILE *fp) const
void set_unicharset(const UNICHARSET &unicharset)
Shape * MutableShape(int shape_id)
bool DeSerialize(bool swap, FILE *fp)
bool IsSubsetOf(const Shape &other) const
bool ContainsMultipleFontProperties(const FontInfoTable &font_table) const
void SetUnicharId(int index, int unichar_id)
void AddToShape(int unichar_id, int font_id)
const Shape & GetShape(int shape_id) const
bool ContainsUnicharAndFont(int unichar_id, int font_id) const
static int SortDescendingRating(const void *t1, const void *t2)
UnicharAndFonts(int uni_id, int font_id)
int destination_index() const
static int SortByUnicharId(const void *v1, const void *v2)