REJMAP Class Reference

#include <rejctmap.h>

List of all members.


Detailed Description

ALL processing of the reject map is done here.

This module may look unneccessarily verbose, but here's the philosophy...

ALL processing of the reject map is done in this module. There are lots of separate calls to set reject/accept flags. These have DELIBERATELY been kept distinct so that this module can decide what to do.

IT IS FUNDAMENTAL THAT ANYONE HACKING THIS CODE UNDERSTANDS THE SIGNIFICANCE OF THIS IMPLIED TEMPORAL ORDERING OF THE FLAGS!!!!

See REJ_FLAGS

Definition at line 244 of file rejctmap.h.

Public Member Functions

Private Attributes


Constructor & Destructor Documentation

REJMAP::REJMAP (  )  [inline]

Definition at line 250 of file rejctmap.h.

References len, NULL, and ptr.

00250              {  //constructor
00251       ptr = NULL;
00252       len = 0;
00253     }

REJMAP::REJMAP ( const REJMAP source  ) 

Classwise copy of reject map

The REJMAP class has been hacked to use alloc_struct instead of new []. This is to reduce memory fragmentation only as it is rather kludgy. alloc_struct by-passes the call to the contsructor of REJ on each array element. Although the constructor is empty, the BITS16 members do have a constructor which sets all the flags to 0. The memset replaces this functionality.

Definition at line 397 of file rejctmap.cpp.

References alloc_struct(), len, length(), NULL, and ptr.

00398                                      {
00399   REJ *to;
00400   REJ *from = source.ptr;
00401   int i;
00402 
00403   len = source.length ();
00404 
00405   if (len > 0) {
00406     ptr = (REJ *) alloc_struct (len * sizeof (REJ), "REJ");
00407     to = ptr;
00408     for (i = 0; i < len; i++) {
00409       *to = *from;
00410       to++;
00411       from++;
00412     }
00413   }
00414   else
00415     ptr = NULL;
00416 }

REJMAP::~REJMAP (  )  [inline]

Definition at line 261 of file rejctmap.h.

References free_struct(), len, NULL, and ptr.

00261                {                 //destructor
00262       if (ptr != NULL)
00263         free_struct (ptr, len * sizeof (REJ), "REJ");
00264     }


Member Function Documentation

INT16 REJMAP::accept_count (  ) 

How many accepted?

Definition at line 462 of file rejctmap.cpp.

References count(), len, and ptr.

Referenced by reject_count().

00462                            {
00463   int i;
00464   INT16 count = 0;
00465 
00466   for (i = 0; i < len; i++) {
00467     if (ptr[i].accepted ())
00468       count++;
00469   }
00470   return count;
00471 }

void REJMAP::full_print ( FILE *  fp  ) 

Definition at line 549 of file rejctmap.cpp.

References len, and ptr.

Referenced by check_debug_pt(), and fixspace_dbg().

00549                                 { 
00550   int i;
00551 
00552   for (i = 0; i < len; i++) {
00553     ptr[i].full_print (fp);
00554     fprintf (fp, "\n");
00555   }
00556 }

void REJMAP::initialise ( INT16  length  ) 

Redefine map

Definition at line 446 of file rejctmap.cpp.

References alloc_struct(), free_struct(), len, NULL, and ptr.

Referenced by classify_word_pass1(), fix_rep_char(), insert_rej_cblobs(), match_word_pass2(), and operator=().

00447                                       {
00448   if (ptr != NULL)
00449     free_struct (ptr, len * sizeof (REJ), "REJ");
00450   len = length;
00451   if (len > 0)
00452     ptr = (REJ *) memset (alloc_struct (len * sizeof (REJ), "REJ"),
00453       0, len * sizeof (REJ));
00454   else
00455     ptr = NULL;
00456 }

INT32 REJMAP::length (  )  const [inline]

Definition at line 276 of file rejctmap.h.

References len.

Referenced by classify_word_pass2(), convert_bad_unlv_chs(), doc_and_block_rejection(), eval_word_spacing(), fp_eval_word_spacing(), garbage_word(), get_rep_char(), insert_rej_cblobs(), make_epaper_choice(), merge_tess_fails(), potential_word_crunch(), re_estimate_x_ht(), recog_all_words(), PAGE_RES_IT::rej_stat_word(), REJMAP(), set_unlv_suspects(), terrible_word_crunch(), unrej_good_quality_words(), word_deletable(), write_map(), and write_results().

00276                          {  //map length
00277       return len;
00278     }

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

assign REJMAP

Definition at line 422 of file rejctmap.cpp.

References initialise(), len, and ptr.

00424   {
00425   REJ *
00426     to;
00427   REJ *
00428     from = source.ptr;
00429   int
00430     i;
00431 
00432   initialise (source.len);
00433   to = ptr;
00434   for (i = 0; i < len; i++) {
00435     *to = *from;
00436     to++;
00437     from++;
00438   }
00439   return *this;
00440 }

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

Definition at line 269 of file rejctmap.h.

References ASSERT_HOST, len, and ptr.

00271     {
00272       ASSERT_HOST (index < len);
00273       return ptr[index];         //no bounds checks
00274     }

void REJMAP::print ( FILE *  fp  ) 

Dump out the reject map to logfile

Definition at line 537 of file rejctmap.cpp.

References len, and ptr.

Referenced by check_block_occ(), check_debug_pt(), classify_word_pass2(), fixspace_dbg(), and re_estimate_x_ht().

00537                            { 
00538   int i;
00539   char buff[512];
00540 
00541   for (i = 0; i < len; i++) {
00542     buff[i] = ptr[i].display_char ();
00543   }
00544   buff[i] = '\0';
00545   fprintf (fp, "\"%s\"", buff);
00546 }

BOOL8 REJMAP::quality_recoverable_rejects (  ) 

Any potential rejs?

Definition at line 491 of file rejctmap.cpp.

References FALSE, len, ptr, and TRUE.

Referenced by unrej_good_quality_words().

00491                                           {
00492   int i;
00493 
00494   for (i = 0; i < len; i++) {
00495     if (ptr[i].accept_if_good_quality ())
00496       return TRUE;
00497   }
00498   return FALSE;
00499 }

BOOL8 REJMAP::recoverable_rejects (  ) 

Any non perm rejs?

Definition at line 477 of file rejctmap.cpp.

References FALSE, len, ptr, and TRUE.

00477                                   {
00478   int i;
00479 
00480   for (i = 0; i < len; i++) {
00481     if (ptr[i].recoverable ())
00482       return TRUE;
00483   }
00484   return FALSE;
00485 }

void REJMAP::rej_word_bad_permuter (  ) 

Reject whole word

Definition at line 612 of file rejctmap.cpp.

References len, and ptr.

00612                                    {
00613   int i;
00614 
00615   for (i = 0; i < len; i++) {
00616     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00617       ptr[i].setrej_bad_permuter ();
00618   }
00619 }

void REJMAP::rej_word_bad_quality (  ) 

Reject whole word

Definition at line 664 of file rejctmap.cpp.

References len, and ptr.

Referenced by recog_all_words().

00664                                   {
00665   int i;
00666 
00667   for (i = 0; i < len; i++) {
00668     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00669       ptr[i].setrej_bad_quality ();
00670   }
00671 }

void REJMAP::rej_word_block_rej (  ) 

Reject whole word

Definition at line 690 of file rejctmap.cpp.

References len, and ptr.

Referenced by doc_and_block_rejection().

00690                                 {
00691   int i;
00692 
00693   for (i = 0; i < len; i++) {
00694     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00695       ptr[i].setrej_block_rej ();
00696   }
00697 }

void REJMAP::rej_word_contains_blanks (  ) 

Reject whole word

Definition at line 599 of file rejctmap.cpp.

References len, and ptr.

00599                                       {
00600   int i;
00601 
00602   for (i = 0; i < len; i++) {
00603     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00604       ptr[i].setrej_contains_blanks ();
00605   }
00606 }

void REJMAP::rej_word_doc_rej (  ) 

Reject whole word

Definition at line 677 of file rejctmap.cpp.

References len, and ptr.

Referenced by reject_whole_page().

00677                               {
00678   int i;
00679 
00680   for (i = 0; i < len; i++) {
00681     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00682       ptr[i].setrej_doc_rej ();
00683   }
00684 }

void REJMAP::rej_word_mostly_rej (  ) 

Reject whole word

Definition at line 651 of file rejctmap.cpp.

References len, and ptr.

00651                                  {
00652   int i;
00653 
00654   for (i = 0; i < len; i++) {
00655     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00656       ptr[i].setrej_mostly_rej ();
00657   }
00658 }

void REJMAP::rej_word_no_alphanums (  ) 

Reject whole word

Definition at line 638 of file rejctmap.cpp.

References len, and ptr.

00638                                    {
00639   int i;
00640 
00641   for (i = 0; i < len; i++) {
00642     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00643       ptr[i].setrej_no_alphanums ();
00644   }
00645 }

void REJMAP::rej_word_not_tess_accepted (  ) 

Reject whole word

Definition at line 586 of file rejctmap.cpp.

References len, and ptr.

00586                                         {
00587   int i;
00588 
00589   for (i = 0; i < len; i++) {
00590     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00591       ptr[i].setrej_not_tess_accepted ();
00592   }
00593 }

void REJMAP::rej_word_row_rej (  ) 

Reject whole word

Definition at line 703 of file rejctmap.cpp.

References len, and ptr.

00703                               {
00704   int i;
00705 
00706   for (i = 0; i < len; i++) {
00707     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00708       ptr[i].setrej_row_rej ();
00709   }
00710 }

void REJMAP::rej_word_small_xht (  ) 

Reject whole word

Definition at line 562 of file rejctmap.cpp.

References len, and ptr.

00562                                 {
00563   int i;
00564 
00565   for (i = 0; i < len; i++) {
00566     ptr[i].setrej_small_xht ();
00567   }
00568 }

void REJMAP::rej_word_tess_failure (  ) 

Reject whole word

Definition at line 574 of file rejctmap.cpp.

References len, and ptr.

Referenced by classify_word_pass1(), match_word_pass2(), and recog_all_words().

00574                                    {
00575   int i;
00576 
00577   for (i = 0; i < len; i++) {
00578     ptr[i].setrej_tess_failure ();
00579   }
00580 }

void REJMAP::rej_word_xht_fixup (  ) 

Reject whole word

Definition at line 625 of file rejctmap.cpp.

References len, and ptr.

Referenced by classify_word_pass2(), and re_estimate_x_ht().

00625                                 {
00626   int i;
00627 
00628   for (i = 0; i < len; i++) {
00629     if (!rejword_only_set_if_accepted || ptr[i].accepted ())
00630       ptr[i].setrej_xht_fixup ();
00631   }
00632 }

INT16 REJMAP::reject_count (  )  [inline]

Definition at line 282 of file rejctmap.h.

References accept_count(), and len.

Referenced by classify_word_pass2(), doc_and_block_rejection(), fixspace_thinks_word_done(), re_estimate_x_ht(), recog_all_words(), and PAGE_RES_IT::rej_stat_word().

00282                          {  //How many rejects?
00283       return len - accept_count ();
00284     }

void REJMAP::remove_pos ( INT16  pos  ) 

Cut out an element

Definition at line 505 of file rejctmap.cpp.

References alloc_struct(), ASSERT_HOST, free_struct(), len, NULL, and ptr.

Referenced by merge_tess_fails(), and write_results().

00507                          {
00508   REJ *new_ptr;                  //new, smaller map
00509   int i;
00510 
00511   ASSERT_HOST (pos >= 0);
00512   ASSERT_HOST (pos < len);
00513   ASSERT_HOST (len > 0);
00514 
00515   len--;
00516   if (len > 0)
00517     new_ptr = (REJ *) memset (alloc_struct (len * sizeof (REJ), "REJ"),
00518       0, len * sizeof (REJ));
00519   else
00520     new_ptr = NULL;
00521 
00522   for (i = 0; i < pos; i++)
00523     new_ptr[i] = ptr[i];         //copy pre pos
00524 
00525   for (; pos < len; pos++)
00526     new_ptr[pos] = ptr[pos + 1]; //copy post pos
00527 
00528                                  //delete old map
00529   free_struct (ptr, (len + 1) * sizeof (REJ), "REJ");
00530   ptr = new_ptr;
00531 }


Member Data Documentation

INT16 REJMAP::len [private]

Definition at line 247 of file rejctmap.h.

Referenced by accept_count(), full_print(), initialise(), length(), operator=(), operator[](), print(), quality_recoverable_rejects(), recoverable_rejects(), rej_word_bad_permuter(), rej_word_bad_quality(), rej_word_block_rej(), rej_word_contains_blanks(), rej_word_doc_rej(), rej_word_mostly_rej(), rej_word_no_alphanums(), rej_word_not_tess_accepted(), rej_word_row_rej(), rej_word_small_xht(), rej_word_tess_failure(), rej_word_xht_fixup(), reject_count(), REJMAP(), remove_pos(), and ~REJMAP().

REJ* REJMAP::ptr [private]

Definition at line 246 of file rejctmap.h.

Referenced by accept_count(), full_print(), initialise(), operator=(), operator[](), print(), quality_recoverable_rejects(), recoverable_rejects(), rej_word_bad_permuter(), rej_word_bad_quality(), rej_word_block_rej(), rej_word_contains_blanks(), rej_word_doc_rej(), rej_word_mostly_rej(), rej_word_no_alphanums(), rej_word_not_tess_accepted(), rej_word_row_rej(), rej_word_small_xht(), rej_word_tess_failure(), rej_word_xht_fixup(), REJMAP(), remove_pos(), and ~REJMAP().


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 19:49:33 2007 for Tesseract by  doxygen 1.5.1