24 #include "config_auto.h" 50 for (
int r = 0; r < num_shape_results; ++r) {
53 return results->
size();
60 int debug,
int keep_this,
62 ASSERT_HOST(
"Must implement ClassifySample!" ==
nullptr);
76 for (
int r = 0; r < num_results; ++r) {
78 if (result !=
nullptr)
80 return results[r].shape_id;
100 #ifndef GRAPHICS_DISABLED 102 if (terminator ==
nullptr) {
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");
112 uint32_t num_features =
sample.num_features();
113 for (uint32_t 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.
empty()) {
181 for (
int f = 0; f < results[i].fonts.
size(); ++f) {
182 tprintf(
" %d", results[i].fonts[f].fontinfo_id);
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;
void FilterDuplicateUnichars(GenericVector< ShapeRating > *results) const
const UNICHARSET & unicharset() const
virtual const UNICHARSET & GetUnicharset() const
virtual void DebugDisplay(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id)
UNICHAR_ID unichar_to_id(const char *const unichar_repr) const
virtual int ClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< ShapeRating > *results)
SVEvent * AwaitEvent(SVEventType type)
bool contains_unichar(const char *const unichar_repr) const
void init_to_size(int size, const T &t)
SVMenuNode * AddChild(const char *txt)
void RenderIntFeature(ScrollView *window, const INT_FEATURE_STRUCT *Feature, ScrollView::Color color)
DLLSYM void tprintf(const char *format,...)
const Shape & GetShape(int shape_id) const
virtual const ShapeTable * GetShapeTable() const =0
virtual int DisplayClassifyAs(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id, int index, PointerVector< ScrollView > *windows)
virtual int UnicharClassifySample(const TrainingSample &sample, Pix *page_pix, int debug, UNICHAR_ID keep_this, GenericVector< UnicharRating > *results)
ScrollView * CreateFeatureSpaceWindow(const char *name, int xpos, int ypos)
const char * id_to_unichar(UNICHAR_ID id) const
bool ContainsUnichar(int unichar_id) const
void AddShapeToResults(const ShapeRating &shape_rating, GenericVector< int > *unichar_map, GenericVector< UnicharRating > *results) const
void BuildMenu(ScrollView *sv, bool menu_bar=true)
virtual int BestShapeForUnichar(const TrainingSample &sample, Pix *page_pix, UNICHAR_ID unichar_id, ShapeRating *result)
virtual void UnicharPrintResults(const char *context, const GenericVector< UnicharRating > &results) const
virtual void PrintResults(const char *context, const GenericVector< ShapeRating > &results) const