tesseract  4.00.00dev
REJMAP Class Reference

#include <rejctmap.h>

Public Member Functions

 REJMAP ()
 
 REJMAP (const REJMAP &rejmap)
 
REJMAPoperator= (const REJMAP &source)
 
 ~REJMAP ()
 
void initialise (inT16 length)
 
REJoperator[] (inT16 index) const
 
inT32 length () const
 
inT16 accept_count ()
 
inT16 reject_count ()
 
void remove_pos (inT16 pos)
 
void print (FILE *fp)
 
void full_print (FILE *fp)
 
BOOL8 recoverable_rejects ()
 
BOOL8 quality_recoverable_rejects ()
 
void rej_word_small_xht ()
 
void rej_word_tess_failure ()
 
void rej_word_not_tess_accepted ()
 
void rej_word_contains_blanks ()
 
void rej_word_bad_permuter ()
 
void rej_word_xht_fixup ()
 
void rej_word_no_alphanums ()
 
void rej_word_mostly_rej ()
 
void rej_word_bad_quality ()
 
void rej_word_doc_rej ()
 
void rej_word_block_rej ()
 
void rej_word_row_rej ()
 

Detailed Description

Definition at line 204 of file rejctmap.h.

Constructor & Destructor Documentation

◆ REJMAP() [1/2]

REJMAP::REJMAP ( )
inline

Definition at line 210 of file rejctmap.h.

210  { //constructor
211  ptr = NULL;
212  len = 0;
213  }

◆ REJMAP() [2/2]

REJMAP::REJMAP ( const REJMAP rejmap)

Definition at line 275 of file rejctmap.cpp.

276  {
277  REJ *to;
278  REJ *from = source.ptr;
279  int i;
280 
281  len = source.length ();
282 
283  if (len > 0) {
284  ptr = (REJ *) malloc(len * sizeof (REJ));
285  to = ptr;
286  for (i = 0; i < len; i++) {
287  *to = *from;
288  to++;
289  from++;
290  }
291  }
292  else
293  ptr = NULL;
294 }
Definition: rejctmap.h:99

◆ ~REJMAP()

REJMAP::~REJMAP ( )
inline

Definition at line 221 of file rejctmap.h.

221  { //destructor
222  free(ptr);
223  }

Member Function Documentation

◆ accept_count()

inT16 REJMAP::accept_count ( )

Definition at line 329 of file rejctmap.cpp.

329  { //How many accepted?
330  int i;
331  inT16 count = 0;
332 
333  for (i = 0; i < len; i++) {
334  if (ptr[i].accepted ())
335  count++;
336  }
337  return count;
338 }
int16_t inT16
Definition: host.h:36
int count(LIST var_list)
Definition: oldlist.cpp:103

◆ full_print()

void REJMAP::full_print ( FILE *  fp)

Definition at line 403 of file rejctmap.cpp.

403  {
404  int i;
405 
406  for (i = 0; i < len; i++) {
407  ptr[i].full_print (fp);
408  fprintf (fp, "\n");
409  }
410 }
void full_print(FILE *fp)
Definition: rejctmap.cpp:234

◆ initialise()

void REJMAP::initialise ( inT16  length)

Definition at line 318 of file rejctmap.cpp.

319  {
320  free(ptr);
321  len = length;
322  if (len > 0)
323  ptr = (REJ *) calloc(len, sizeof(REJ));
324  else
325  ptr = NULL;
326 }
inT32 length() const
Definition: rejctmap.h:235
Definition: rejctmap.h:99

◆ length()

inT32 REJMAP::length ( ) const
inline

Definition at line 235 of file rejctmap.h.

235  { //map length
236  return len;
237  }

◆ operator=()

REJMAP & REJMAP::operator= ( const REJMAP source)

Definition at line 297 of file rejctmap.cpp.

299  {
300  REJ *
301  to;
302  REJ *
303  from = source.ptr;
304  int
305  i;
306 
307  initialise (source.len);
308  to = ptr;
309  for (i = 0; i < len; i++) {
310  *to = *from;
311  to++;
312  from++;
313  }
314  return *this;
315 }
void initialise(inT16 length)
Definition: rejctmap.cpp:318
Definition: rejctmap.h:99

◆ operator[]()

REJ& REJMAP::operator[] ( inT16  index) const
inline

Definition at line 228 of file rejctmap.h.

230  {
231  ASSERT_HOST (index < len);
232  return ptr[index]; //no bounds checks
233  }
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ print()

void REJMAP::print ( FILE *  fp)

Definition at line 391 of file rejctmap.cpp.

391  {
392  int i;
393  char buff[512];
394 
395  for (i = 0; i < len; i++) {
396  buff[i] = ptr[i].display_char ();
397  }
398  buff[i] = '\0';
399  fprintf (fp, "\"%s\"", buff);
400 }
char display_char()
Definition: rejctmap.h:142

◆ quality_recoverable_rejects()

BOOL8 REJMAP::quality_recoverable_rejects ( )

Definition at line 352 of file rejctmap.cpp.

352  { //Any potential rejs?
353  int i;
354 
355  for (i = 0; i < len; i++) {
356  if (ptr[i].accept_if_good_quality ())
357  return TRUE;
358  }
359  return FALSE;
360 }
#define TRUE
Definition: capi.h:45
#define FALSE
Definition: capi.h:46

◆ recoverable_rejects()

BOOL8 REJMAP::recoverable_rejects ( )

Definition at line 341 of file rejctmap.cpp.

341  { //Any non perm rejs?
342  int i;
343 
344  for (i = 0; i < len; i++) {
345  if (ptr[i].recoverable ())
346  return TRUE;
347  }
348  return FALSE;
349 }
#define TRUE
Definition: capi.h:45
#define FALSE
Definition: capi.h:46

◆ rej_word_bad_permuter()

void REJMAP::rej_word_bad_permuter ( )

Definition at line 449 of file rejctmap.cpp.

449  { //Reject whole word
450  int i;
451 
452  for (i = 0; i < len; i++) {
453  if (ptr[i].accepted()) ptr[i].setrej_bad_permuter ();
454  }
455 }
void setrej_bad_permuter()
Definition: rejctmap.cpp:153

◆ rej_word_bad_quality()

void REJMAP::rej_word_bad_quality ( )

Definition at line 485 of file rejctmap.cpp.

485  { //Reject whole word
486  int i;
487 
488  for (i = 0; i < len; i++) {
489  if (ptr[i].accepted()) ptr[i].setrej_bad_quality();
490  }
491 }
void setrej_bad_quality()
Definition: rejctmap.cpp:183

◆ rej_word_block_rej()

void REJMAP::rej_word_block_rej ( )

Definition at line 503 of file rejctmap.cpp.

503  { //Reject whole word
504  int i;
505 
506  for (i = 0; i < len; i++) {
507  if (ptr[i].accepted()) ptr[i].setrej_block_rej();
508  }
509 }
void setrej_block_rej()
Definition: rejctmap.cpp:193

◆ rej_word_contains_blanks()

void REJMAP::rej_word_contains_blanks ( )

Definition at line 440 of file rejctmap.cpp.

440  { //Reject whole word
441  int i;
442 
443  for (i = 0; i < len; i++) {
444  if (ptr[i].accepted()) ptr[i].setrej_contains_blanks();
445  }
446 }
void setrej_contains_blanks()
Definition: rejctmap.cpp:147

◆ rej_word_doc_rej()

void REJMAP::rej_word_doc_rej ( )

Definition at line 494 of file rejctmap.cpp.

494  { //Reject whole word
495  int i;
496 
497  for (i = 0; i < len; i++) {
498  if (ptr[i].accepted()) ptr[i].setrej_doc_rej();
499  }
500 }
void setrej_doc_rej()
Definition: rejctmap.cpp:188

◆ rej_word_mostly_rej()

void REJMAP::rej_word_mostly_rej ( )

Definition at line 476 of file rejctmap.cpp.

476  { //Reject whole word
477  int i;
478 
479  for (i = 0; i < len; i++) {
480  if (ptr[i].accepted()) ptr[i].setrej_mostly_rej();
481  }
482 }
void setrej_mostly_rej()
Definition: rejctmap.cpp:173

◆ rej_word_no_alphanums()

void REJMAP::rej_word_no_alphanums ( )

Definition at line 467 of file rejctmap.cpp.

467  { //Reject whole word
468  int i;
469 
470  for (i = 0; i < len; i++) {
471  if (ptr[i].accepted()) ptr[i].setrej_no_alphanums();
472  }
473 }
void setrej_no_alphanums()
Definition: rejctmap.cpp:168

◆ rej_word_not_tess_accepted()

void REJMAP::rej_word_not_tess_accepted ( )

Definition at line 431 of file rejctmap.cpp.

431  { //Reject whole word
432  int i;
433 
434  for (i = 0; i < len; i++) {
435  if (ptr[i].accepted()) ptr[i].setrej_not_tess_accepted();
436  }
437 }
void setrej_not_tess_accepted()
Definition: rejctmap.cpp:141

◆ rej_word_row_rej()

void REJMAP::rej_word_row_rej ( )

Definition at line 512 of file rejctmap.cpp.

512  { //Reject whole word
513  int i;
514 
515  for (i = 0; i < len; i++) {
516  if (ptr[i].accepted()) ptr[i].setrej_row_rej();
517  }
518 }
void setrej_row_rej()
Definition: rejctmap.cpp:198

◆ rej_word_small_xht()

void REJMAP::rej_word_small_xht ( )

Definition at line 413 of file rejctmap.cpp.

413  { //Reject whole word
414  int i;
415 
416  for (i = 0; i < len; i++) {
417  ptr[i].setrej_small_xht ();
418  }
419 }
void setrej_small_xht()
Definition: rejctmap.cpp:101

◆ rej_word_tess_failure()

void REJMAP::rej_word_tess_failure ( )

Definition at line 422 of file rejctmap.cpp.

422  { //Reject whole word
423  int i;
424 
425  for (i = 0; i < len; i++) {
426  ptr[i].setrej_tess_failure ();
427  }
428 }
void setrej_tess_failure()
Definition: rejctmap.cpp:96

◆ rej_word_xht_fixup()

void REJMAP::rej_word_xht_fixup ( )

Definition at line 458 of file rejctmap.cpp.

458  { //Reject whole word
459  int i;
460 
461  for (i = 0; i < len; i++) {
462  if (ptr[i].accepted()) ptr[i].setrej_xht_fixup();
463  }
464 }
void setrej_xht_fixup()
Definition: rejctmap.cpp:178

◆ reject_count()

inT16 REJMAP::reject_count ( )
inline

Definition at line 241 of file rejctmap.h.

241  { //How many rejects?
242  return len - accept_count ();
243  }
inT16 accept_count()
Definition: rejctmap.cpp:329

◆ remove_pos()

void REJMAP::remove_pos ( inT16  pos)

Definition at line 363 of file rejctmap.cpp.

365  {
366  REJ *new_ptr; //new, smaller map
367  int i;
368 
369  ASSERT_HOST (pos >= 0);
370  ASSERT_HOST (pos < len);
371  ASSERT_HOST (len > 0);
372 
373  len--;
374  if (len > 0)
375  new_ptr = (REJ *) malloc(len * sizeof(REJ));
376  else
377  new_ptr = NULL;
378 
379  for (i = 0; i < pos; i++)
380  new_ptr[i] = ptr[i]; //copy pre pos
381 
382  for (; pos < len; pos++)
383  new_ptr[pos] = ptr[pos + 1]; //copy post pos
384 
385  //delete old map
386  free(ptr);
387  ptr = new_ptr;
388 }
#define ASSERT_HOST(x)
Definition: errcode.h:84
Definition: rejctmap.h:99

The documentation for this class was generated from the following files: