24 #include "config_auto.h"
45 int num_shape_results =
ClassifySample(sample, page_pix, debug, keep_this,
50 for (
int r = 0; r < num_shape_results; ++r) {
53 return results->
size();
60 int debug,
int keep_this,
75 int num_results =
ClassifySample(sample, page_pix, 0, unichar_id, &results);
76 for (
int r = 0; r < num_results; ++r) {
80 return results[r].shape_id;
100 #ifndef GRAPHICS_DISABLED
102 if (terminator ==
NULL) {
103 terminator =
new ScrollView(
"XIT", 0, 0, 50, 50, 50, 50,
true);
108 popup_menu->
AddChild(
"Choose class to debug", 0,
"x",
"Class to debug");
113 for (
int f = 0; f < num_features; ++f) {
124 if (unichar_id >= 0) {
125 tprintf(
"Debugging class %d = %s\n",
130 tprintf(
"Invalid unichar_id: %d\n", unichar_id);
133 if (unichar_id >= 0) {
134 tprintf(
"Debugged class %d = %s\n",
137 tprintf(
"Right-click in ClassifierDebug window to choose debug class,");
138 tprintf(
" Left-click or close window to quit...\n");
141 old_unichar_id = unichar_id;
152 }
while (unichar_id == old_unichar_id &&
156 #endif // GRAPHICS_DISABLED
176 for (
int i = 0; i < results.
size(); ++i) {
177 tprintf(
"%g: c_id=%d=%s", results[i].rating, results[i].unichar_id,
179 if (results[i].fonts.
size() != 0) {
181 for (
int f = 0; f < results[i].fonts.
size(); ++f) {
182 tprintf(
" %d", results[i].fonts[f]);
191 for (
int i = 0; i < results.
size(); ++i) {
192 tprintf(
"%g:", results[i].rating);
193 if (results[i].joined)
195 if (results[i].broken)
208 for (
int r = 0; r < results->
size(); ++r) {
210 const Shape& shape_r = shapes->
GetShape((*results)[r].shape_id);
212 for (c = 0; c < shape_r.
size(); ++c) {
213 int unichar_id = shape_r[c].unichar_id;
215 for (s = 0; s < r; ++s) {
216 const Shape& shape_s = shapes->
GetShape((*results)[s].shape_id);
223 if (c == shape_r.
size())
226 filtered_results.
push_back((*results)[r]);
228 *results = filtered_results;
virtual void UnicharPrintResults(const char *context, const GenericVector< UnicharRating > &results) const
virtual int UnicharClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results)
virtual const ShapeTable * GetShapeTable() const =0
const UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
virtual void DebugDisplay(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id)
const INT_FEATURE_STRUCT * features() const
void BuildMenu(ScrollView *sv, bool menu_bar=true)
virtual int ClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< ShapeRating > *results)
bool ContainsUnichar(int unichar_id) const
void FilterDuplicateUnichars(GenericVector< ShapeRating > *results) const
virtual void PrintResults(const char *context, const GenericVector< ShapeRating > &results) const
const char *const id_to_unichar(UNICHAR_ID id) const
void init_to_size(int size, T t)
virtual int BestShapeForUnichar(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id, ShapeRating *result)
SVEvent * AwaitEvent(SVEventType type)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
void AddShapeToResults(const ShapeRating &shape_rating, GenericVector< int > *unichar_map, GenericVector< UnicharRating > *results) const
bool contains_unichar(const char *const unichar_repr) const
const UNICHARSET & unicharset() const
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
virtual int DisplayClassifyAs(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id, int index, PointerVector< ScrollView > *windows)
SVMenuNode * AddChild(const char *txt)
const Shape & GetShape(int shape_id) const
virtual const UNICHARSET & GetUnicharset() const