tesseract  4.0.0-1-g2a2b
WERD Class Reference

#include <werd.h>

Inheritance diagram for WERD:
ELIST2_LINK

Public Member Functions

 WERD ()=default
 
 WERD (C_BLOB_LIST *blob_list, uint8_t blanks, const char *text)
 
 WERD (C_BLOB_LIST *blob_list, WERD *clone)
 
WERDConstructFromSingleBlob (bool bol, bool eol, C_BLOB *blob)
 
 ~WERD ()=default
 
WERDoperator= (const WERD &source)
 
WERDConstructWerdWithNewBlobs (C_BLOB_LIST *all_blobs, C_BLOB_LIST *orphan_blobs)
 
C_BLOB_LIST * rej_cblob_list ()
 
C_BLOB_LIST * cblob_list ()
 
uint8_t space ()
 
void set_blanks (uint8_t new_blanks)
 
int script_id () const
 
void set_script_id (int id)
 
TBOX bounding_box () const
 
TBOX restricted_bounding_box (bool upper_dots, bool lower_dots) const
 
TBOX true_bounding_box () const
 
const char * text () const
 
void set_text (const char *new_text)
 
bool flag (WERD_FLAGS mask) const
 
void set_flag (WERD_FLAGS mask, bool value)
 
bool display_flag (uint8_t flag) const
 
void set_display_flag (uint8_t flag, bool value)
 
WERDshallow_copy ()
 
void move (const ICOORD vec)
 
void join_on (WERD *other)
 
void copy_on (WERD *other)
 
void print ()
 
void plot (ScrollView *window, ScrollView::Color colour)
 
void plot (ScrollView *window)
 
void plot_rej_blobs (ScrollView *window)
 
void CleanNoise (float size_threshold)
 
void GetNoiseOutlines (GenericVector< C_OUTLINE *> *outlines)
 
bool AddSelectedOutlines (const GenericVector< bool > &wanted, const GenericVector< C_BLOB *> &target_blobs, const GenericVector< C_OUTLINE *> &outlines, bool *make_next_word_fuzzy)
 
- Public Member Functions inherited from ELIST2_LINK
 ELIST2_LINK ()
 
 ELIST2_LINK (const ELIST2_LINK &)
 
void operator= (const ELIST2_LINK &)
 

Static Public Member Functions

static ScrollView::Color NextColor (ScrollView::Color colour)
 

Detailed Description

Definition at line 59 of file werd.h.

Constructor & Destructor Documentation

◆ WERD() [1/3]

WERD::WERD ( )
default

◆ WERD() [2/3]

WERD::WERD ( C_BLOB_LIST *  blob_list,
uint8_t  blank_count,
const char *  text 
)

WERD::WERD

Constructor to build a WERD from a list of C_BLOBs. blob_list The C_BLOBs (in word order) are not copied; we take its elements and put them in our lists. blank_count blanks in front of the word text correct text, outlives this WERD

Definition at line 47 of file werd.cpp.

48  : blanks(blank_count),
49  flags(0),
50  script_id_(0),
51  correct(text) {
52  C_BLOB_IT start_it = &cblobs;
53  C_BLOB_IT rej_cblob_it = &rej_cblobs;
54  C_OUTLINE_IT c_outline_it;
55  int16_t inverted_vote = 0;
56  int16_t non_inverted_vote = 0;
57 
58  // Move blob_list's elements into cblobs.
59  start_it.add_list_after(blob_list);
60 
61  /*
62  Set white on black flag for the WERD, moving any duff blobs onto the
63  rej_cblobs list.
64  First, walk the cblobs checking the inverse flag for each outline of each
65  cblob. If a cblob has inconsistent flag settings for its different
66  outlines, move the blob to the reject list. Otherwise, increment the
67  appropriate w-on-b or b-on-w vote for the word.
68 
69  Now set the inversion flag for the WERD by maximum vote.
70 
71  Walk the blobs again, moving any blob whose inversion flag does not agree
72  with the concencus onto the reject list.
73  */
74  start_it.set_to_list(&cblobs);
75  if (start_it.empty())
76  return;
77  for (start_it.mark_cycle_pt(); !start_it.cycled_list(); start_it.forward()) {
78  bool reject_blob = false;
79  bool blob_inverted;
80 
81  c_outline_it.set_to_list(start_it.data()->out_list());
82  blob_inverted = c_outline_it.data()->flag(COUT_INVERSE);
83  for (c_outline_it.mark_cycle_pt();
84  !c_outline_it.cycled_list() && !reject_blob;
85  c_outline_it.forward()) {
86  reject_blob = c_outline_it.data()->flag(COUT_INVERSE) != blob_inverted;
87  }
88  if (reject_blob) {
89  rej_cblob_it.add_after_then_move(start_it.extract());
90  } else {
91  if (blob_inverted)
92  inverted_vote++;
93  else
94  non_inverted_vote++;
95  }
96  }
97 
98  flags.set_bit(W_INVERSE, (inverted_vote > non_inverted_vote));
99 
100  start_it.set_to_list(&cblobs);
101  if (start_it.empty())
102  return;
103  for (start_it.mark_cycle_pt(); !start_it.cycled_list(); start_it.forward()) {
104  c_outline_it.set_to_list(start_it.data()->out_list());
105  if (c_outline_it.data()->flag(COUT_INVERSE) != flags.bit(W_INVERSE))
106  rej_cblob_it.add_after_then_move(start_it.extract());
107  }
108 }
Definition: werd.h:43
bool bit(uint8_t bit_num) const
Definition: bits16.h:57
void set_bit(uint8_t bit_num, bool value)
Definition: bits16.h:48
const char * text() const
Definition: werd.h:123

◆ WERD() [3/3]

WERD::WERD ( C_BLOB_LIST *  blob_list,
WERD clone 
)

WERD::WERD

Constructor to build a WERD from a list of C_BLOBs. The C_BLOBs are not copied so the source list is emptied.

Definition at line 118 of file werd.cpp.

120  : flags(clone->flags),
121  script_id_(clone->script_id_),
122  correct(clone->correct) {
123  C_BLOB_IT start_it = blob_list; // iterator
124  C_BLOB_IT end_it = blob_list; // another
125 
126  while (!end_it.at_last ())
127  end_it.forward (); //move to last
128  (reinterpret_cast<C_BLOB_LIST*>(&cblobs))->assign_to_sublist(&start_it, &end_it);
129  //move to our list
130  blanks = clone->blanks;
131  // fprintf(stderr,"Wrong constructor!!!!\n");
132 }

◆ ~WERD()

WERD::~WERD ( )
default

Member Function Documentation

◆ AddSelectedOutlines()

bool WERD::AddSelectedOutlines ( const GenericVector< bool > &  wanted,
const GenericVector< C_BLOB *> &  target_blobs,
const GenericVector< C_OUTLINE *> &  outlines,
bool *  make_next_word_fuzzy 
)

Definition at line 547 of file werd.cpp.

550  {
551  bool outline_added_to_start = false;
552  if (make_next_word_fuzzy != nullptr) *make_next_word_fuzzy = false;
553  C_BLOB_IT rej_it(&rej_cblobs);
554  for (int i = 0; i < outlines.size(); ++i) {
555  C_OUTLINE* outline = outlines[i];
556  if (outline == nullptr) continue; // Already used it.
557  if (wanted[i]) {
558  C_BLOB* target_blob = target_blobs[i];
559  TBOX noise_box = outline->bounding_box();
560  if (target_blob == nullptr) {
561  target_blob = new C_BLOB(outline);
562  // Need to find the insertion point.
563  C_BLOB_IT blob_it(&cblobs);
564  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list();
565  blob_it.forward()) {
566  C_BLOB* blob = blob_it.data();
567  TBOX blob_box = blob->bounding_box();
568  if (blob_box.left() > noise_box.left()) {
569  if (blob_it.at_first() && !flag(W_FUZZY_SP) && !flag(W_FUZZY_NON)) {
570  // We might want to join this word to its predecessor.
571  outline_added_to_start = true;
572  }
573  blob_it.add_before_stay_put(target_blob);
574  break;
575  }
576  }
577  if (blob_it.cycled_list()) {
578  blob_it.add_to_end(target_blob);
579  if (make_next_word_fuzzy != nullptr) *make_next_word_fuzzy = true;
580  }
581  // Add all consecutive wanted, but null-blob outlines to same blob.
582  C_OUTLINE_IT ol_it(target_blob->out_list());
583  while (i + 1 < outlines.size() && wanted[i + 1] &&
584  target_blobs[i + 1] == nullptr) {
585  ++i;
586  ol_it.add_to_end(outlines[i]);
587  }
588  } else {
589  // Insert outline into this blob.
590  C_OUTLINE_IT ol_it(target_blob->out_list());
591  ol_it.add_to_end(outline);
592  }
593  } else {
594  // Put back on noise list.
595  rej_it.add_to_end(new C_BLOB(outline));
596  }
597  }
598  return outline_added_to_start;
599 }
int size() const
Definition: genericvector.h:71
Definition: rect.h:34
int16_t left() const
Definition: rect.h:72
bool flag(WERD_FLAGS mask) const
Definition: werd.h:126
const TBOX & bounding_box() const
Definition: coutln.h:113
TBOX bounding_box() const
Definition: stepblob.cpp:255
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:70

◆ bounding_box()

TBOX WERD::bounding_box ( ) const

WERD::bounding_box

Return the bounding box of the WERD. This is quite a mess to compute! ORIGINALLY, REJECT CBLOBS WERE EXCLUDED, however, this led to bugs when the words on the row were re-sorted. The original words were built with reject blobs included. The FUZZY SPACE flags were set accordingly. If ALL the blobs in a word are rejected the BB for the word is nullptr, causing the sort to screw up, leading to the erroneous possibility of the first word in a row being marked as FUZZY space.

Definition at line 159 of file werd.cpp.

159 { return restricted_bounding_box(true, true); }
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const
Definition: werd.cpp:163

◆ cblob_list()

C_BLOB_LIST* WERD::cblob_list ( )
inline

Definition at line 98 of file werd.h.

98  { // get compact blobs
99  return &cblobs;
100  }

◆ CleanNoise()

void WERD::CleanNoise ( float  size_threshold)

Definition at line 505 of file werd.cpp.

505  {
506  C_BLOB_IT blob_it(&cblobs);
507  C_BLOB_IT rej_it(&rej_cblobs);
508  for (blob_it.mark_cycle_pt(); !blob_it.cycled_list(); blob_it.forward()) {
509  C_BLOB* blob = blob_it.data();
510  C_OUTLINE_IT ol_it(blob->out_list());
511  for (ol_it.mark_cycle_pt(); !ol_it.cycled_list(); ol_it.forward()) {
512  C_OUTLINE* outline = ol_it.data();
513  TBOX ol_box = outline->bounding_box();
514  int ol_size =
515  ol_box.width() > ol_box.height() ? ol_box.width() : ol_box.height();
516  if (ol_size < size_threshold) {
517  // This outline is too small. Move it to a separate blob in the
518  // reject blobs list.
519  C_BLOB* rej_blob = new C_BLOB(ol_it.extract());
520  rej_it.add_after_then_move(rej_blob);
521  }
522  }
523  if (blob->out_list()->empty()) delete blob_it.extract();
524  }
525 }
Definition: rect.h:34
int16_t width() const
Definition: rect.h:115
const TBOX & bounding_box() const
Definition: coutln.h:113
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:70
int16_t height() const
Definition: rect.h:108

◆ ConstructFromSingleBlob()

WERD * WERD::ConstructFromSingleBlob ( bool  bol,
bool  eol,
C_BLOB blob 
)

Definition at line 136 of file werd.cpp.

136  {
137  C_BLOB_LIST temp_blobs;
138  C_BLOB_IT temp_it(&temp_blobs);
139  temp_it.add_after_then_move(blob);
140  WERD* blob_word = new WERD(&temp_blobs, this);
141  blob_word->set_flag(W_BOL, bol);
142  blob_word->set_flag(W_EOL, eol);
143  return blob_word;
144 }
Definition: werd.h:35
void set_flag(WERD_FLAGS mask, bool value)
Definition: werd.h:127
Definition: werd.h:59
Definition: werd.h:34
WERD()=default

◆ ConstructWerdWithNewBlobs()

WERD * WERD::ConstructWerdWithNewBlobs ( C_BLOB_LIST *  all_blobs,
C_BLOB_LIST *  orphan_blobs 
)

WERD::ConstructWerdWithNewBlobs()

This method returns a new werd constructed using the blobs in the input all_blobs list, which correspond to the blobs in this werd object. The blobs used to construct the new word are consumed and removed from the input all_blobs list. Returns nullptr if the word couldn't be constructed. Returns original blobs for which no matches were found in the output list orphan_blobs (appends).

Definition at line 411 of file werd.cpp.

412  {
413  C_BLOB_LIST current_blob_list;
414  C_BLOB_IT werd_blobs_it(&current_blob_list);
415  // Add the word's c_blobs.
416  werd_blobs_it.add_list_after(cblob_list());
417 
418  // New blob list. These contain the blobs which will form the new word.
419  C_BLOB_LIST new_werd_blobs;
420  C_BLOB_IT new_blobs_it(&new_werd_blobs);
421 
422  // not_found_blobs contains the list of current word's blobs for which a
423  // corresponding blob wasn't found in the input all_blobs list.
424  C_BLOB_LIST not_found_blobs;
425  C_BLOB_IT not_found_it(&not_found_blobs);
426  not_found_it.move_to_last();
427 
428  werd_blobs_it.move_to_first();
429  for (werd_blobs_it.mark_cycle_pt(); !werd_blobs_it.cycled_list();
430  werd_blobs_it.forward()) {
431  C_BLOB* werd_blob = werd_blobs_it.extract();
432  TBOX werd_blob_box = werd_blob->bounding_box();
433  bool found = false;
434  // Now find the corresponding blob for this blob in the all_blobs
435  // list. For now, follow the inefficient method of pairwise
436  // comparisons. Ideally, one can pre-bucket the blobs by row.
437  C_BLOB_IT all_blobs_it(all_blobs);
438  for (all_blobs_it.mark_cycle_pt(); !all_blobs_it.cycled_list();
439  all_blobs_it.forward()) {
440  C_BLOB* a_blob = all_blobs_it.data();
441  // Compute the overlap of the two blobs. If major, a_blob should
442  // be added to the new blobs list.
443  TBOX a_blob_box = a_blob->bounding_box();
444  if (a_blob_box.null_box()) {
445  tprintf("Bounding box couldn't be ascertained\n");
446  }
447  if (werd_blob_box.contains(a_blob_box) ||
448  werd_blob_box.major_overlap(a_blob_box)) {
449  // Old blobs are from minimal splits, therefore are expected to be
450  // bigger. The new small blobs should cover a significant portion.
451  // This is it.
452  all_blobs_it.extract();
453  new_blobs_it.add_after_then_move(a_blob);
454  found = true;
455  }
456  }
457  if (!found) {
458  not_found_it.add_after_then_move(werd_blob);
459  } else {
460  delete werd_blob;
461  }
462  }
463  // Iterate over all not found blobs. Some of them may be due to
464  // under-segmentation (which is OK, since the corresponding blob is already
465  // in the list in that case.
466  not_found_it.move_to_first();
467  for (not_found_it.mark_cycle_pt(); !not_found_it.cycled_list();
468  not_found_it.forward()) {
469  C_BLOB* not_found = not_found_it.data();
470  TBOX not_found_box = not_found->bounding_box();
471  C_BLOB_IT existing_blobs_it(new_blobs_it);
472  for (existing_blobs_it.mark_cycle_pt(); !existing_blobs_it.cycled_list();
473  existing_blobs_it.forward()) {
474  C_BLOB* a_blob = existing_blobs_it.data();
475  TBOX a_blob_box = a_blob->bounding_box();
476  if ((not_found_box.major_overlap(a_blob_box) ||
477  a_blob_box.major_overlap(not_found_box)) &&
478  not_found_box.y_overlap_fraction(a_blob_box) > 0.8) {
479  // Already taken care of.
480  delete not_found_it.extract();
481  break;
482  }
483  }
484  }
485  if (orphan_blobs) {
486  C_BLOB_IT orphan_blobs_it(orphan_blobs);
487  orphan_blobs_it.move_to_last();
488  orphan_blobs_it.add_list_after(&not_found_blobs);
489  }
490 
491  // New blobs are ready. Create a new werd object with these.
492  WERD* new_werd = nullptr;
493  if (!new_werd_blobs.empty()) {
494  new_werd = new WERD(&new_werd_blobs, this);
495  } else {
496  // Add the blobs back to this word so that it can be reused.
497  C_BLOB_IT this_list_it(cblob_list());
498  this_list_it.add_list_after(&not_found_blobs);
499  }
500  return new_werd;
501 }
bool null_box() const
Definition: rect.h:50
Definition: rect.h:34
double y_overlap_fraction(const TBOX &box) const
Definition: rect.h:479
bool major_overlap(const TBOX &box) const
Definition: rect.h:368
Definition: werd.h:59
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
C_BLOB_LIST * cblob_list()
Definition: werd.h:98
WERD()=default
TBOX bounding_box() const
Definition: stepblob.cpp:255
bool contains(const FCOORD pt) const
Definition: rect.h:333

◆ copy_on()

void WERD::copy_on ( WERD other)

WERD::copy_on

Copy blobs from other word onto this one.

Definition at line 233 of file werd.cpp.

233  {
234  bool reversed = other->bounding_box().left() < bounding_box().left();
235  C_BLOB_IT c_blob_it(&cblobs);
236  C_BLOB_LIST c_blobs;
237 
238  c_blobs.deep_copy(&other->cblobs, &C_BLOB::deep_copy);
239  if (reversed) {
240  c_blob_it.add_list_before(&c_blobs);
241  } else {
242  c_blob_it.move_to_last();
243  c_blob_it.add_list_after(&c_blobs);
244  }
245  if (!other->rej_cblobs.empty()) {
246  C_BLOB_IT rej_c_blob_it(&rej_cblobs);
247  C_BLOB_LIST new_rej_c_blobs;
248 
249  new_rej_c_blobs.deep_copy(&other->rej_cblobs, &C_BLOB::deep_copy);
250  if (reversed) {
251  rej_c_blob_it.add_list_before(&new_rej_c_blobs);
252  } else {
253  rej_c_blob_it.move_to_last();
254  rej_c_blob_it.add_list_after(&new_rej_c_blobs);
255  }
256  }
257 }
TBOX bounding_box() const
Definition: werd.cpp:159
int16_t left() const
Definition: rect.h:72
static C_BLOB * deep_copy(const C_BLOB *src)
Definition: stepblob.h:119

◆ display_flag()

bool WERD::display_flag ( uint8_t  flag) const
inline

Definition at line 129 of file werd.h.

129 { return disp_flags.bit(flag); }
bool bit(uint8_t bit_num) const
Definition: bits16.h:57
bool flag(WERD_FLAGS mask) const
Definition: werd.h:126

◆ flag()

bool WERD::flag ( WERD_FLAGS  mask) const
inline

Definition at line 126 of file werd.h.

126 { return flags.bit(mask); }
bool bit(uint8_t bit_num) const
Definition: bits16.h:57

◆ GetNoiseOutlines()

void WERD::GetNoiseOutlines ( GenericVector< C_OUTLINE *> *  outlines)

Definition at line 529 of file werd.cpp.

529  {
530  C_BLOB_IT rej_it(&rej_cblobs);
531  for (rej_it.mark_cycle_pt(); !rej_it.empty(); rej_it.forward()) {
532  C_BLOB* blob = rej_it.extract();
533  C_OUTLINE_IT ol_it(blob->out_list());
534  outlines->push_back(ol_it.extract());
535  delete blob;
536  }
537 }
int push_back(T object)
C_OUTLINE_LIST * out_list()
Definition: stepblob.h:70

◆ join_on()

void WERD::join_on ( WERD other)

WERD::join_on

Join other word onto this one. Delete the old word.

Definition at line 210 of file werd.cpp.

210  {
211  C_BLOB_IT blob_it(&cblobs);
212  C_BLOB_IT src_it(&other->cblobs);
213  C_BLOB_IT rej_cblob_it(&rej_cblobs);
214  C_BLOB_IT src_rej_it(&other->rej_cblobs);
215 
216  while (!src_it.empty()) {
217  blob_it.add_to_end(src_it.extract());
218  src_it.forward();
219  }
220  while (!src_rej_it.empty()) {
221  rej_cblob_it.add_to_end(src_rej_it.extract());
222  src_rej_it.forward();
223  }
224 }

◆ move()

void WERD::move ( const ICOORD  vec)

WERD::move

Reposition WERD by vector NOTE!! REJECT CBLOBS ARE NOT MOVED

Definition at line 197 of file werd.cpp.

197  {
198  C_BLOB_IT cblob_it(&cblobs); // cblob iterator
199 
200  for (cblob_it.mark_cycle_pt(); !cblob_it.cycled_list(); cblob_it.forward())
201  cblob_it.data()->move(vec);
202 }

◆ NextColor()

ScrollView::Color WERD::NextColor ( ScrollView::Color  colour)
static

Definition at line 305 of file werd.cpp.

305  {
306  ScrollView::Color next = static_cast<ScrollView::Color>(colour + 1);
307  if (next >= LAST_COLOUR || next < FIRST_COLOUR)
308  next = FIRST_COLOUR;
309  return next;
310 }
#define LAST_COLOUR
Definition: werd.cpp:30
#define FIRST_COLOUR
Definition: werd.cpp:29

◆ operator=()

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

WERD::operator=

Assign a word, DEEP copying the blob list

Definition at line 368 of file werd.cpp.

368  {
369  this->ELIST2_LINK::operator= (source);
370  blanks = source.blanks;
371  flags = source.flags;
372  script_id_ = source.script_id_;
373  dummy = source.dummy;
374  correct = source.correct;
375  if (!cblobs.empty())
376  cblobs.clear();
377  cblobs.deep_copy(&source.cblobs, &C_BLOB::deep_copy);
378 
379  if (!rej_cblobs.empty())
380  rej_cblobs.clear();
381  rej_cblobs.deep_copy(&source.rej_cblobs, &C_BLOB::deep_copy);
382  return *this;
383 }
void operator=(const ELIST2_LINK &)
Definition: elst2.h:76
static C_BLOB * deep_copy(const C_BLOB *src)
Definition: stepblob.h:119

◆ plot() [1/2]

void WERD::plot ( ScrollView window,
ScrollView::Color  colour 
)

WERD::plot

Draw the WERD in the given colour.

Definition at line 296 of file werd.cpp.

296  {
297  C_BLOB_IT it = &cblobs;
298  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
299  it.data()->plot(window, colour, colour);
300  }
301  plot_rej_blobs(window);
302 }
void plot_rej_blobs(ScrollView *window)
Definition: werd.cpp:336

◆ plot() [2/2]

void WERD::plot ( ScrollView window)

WERD::plot

Draw the WERD in rainbow colours in window.

Definition at line 318 of file werd.cpp.

318  {
320  C_BLOB_IT it = &cblobs;
321  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
322  it.data()->plot(window, colour, CHILD_COLOUR);
323  colour = NextColor(colour);
324  }
325  plot_rej_blobs(window);
326 }
void plot_rej_blobs(ScrollView *window)
Definition: werd.cpp:336
static ScrollView::Color NextColor(ScrollView::Color colour)
Definition: werd.cpp:305
#define CHILD_COLOUR
Definition: werd.cpp:31
#define FIRST_COLOUR
Definition: werd.cpp:29

◆ plot_rej_blobs()

void WERD::plot_rej_blobs ( ScrollView window)

WERD::plot_rej_blobs

Draw the WERD rejected blobs in window - ALWAYS GREY

Definition at line 336 of file werd.cpp.

336  {
337  C_BLOB_IT it = &rej_cblobs;
338  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
339  it.data()->plot(window, ScrollView::GREY, ScrollView::GREY);
340  }
341 }

◆ print()

void WERD::print ( )

WERD::print

Display members

Definition at line 265 of file werd.cpp.

265  {
266  tprintf("Blanks= %d\n", blanks);
267  bounding_box().print();
268  tprintf("Flags = %d = 0%o\n", flags.val, flags.val);
269  tprintf(" W_SEGMENTED = %s\n", flags.bit(W_SEGMENTED) ? "TRUE" : "FALSE ");
270  tprintf(" W_ITALIC = %s\n", flags.bit(W_ITALIC) ? "TRUE" : "FALSE ");
271  tprintf(" W_BOL = %s\n", flags.bit(W_BOL) ? "TRUE" : "FALSE ");
272  tprintf(" W_EOL = %s\n", flags.bit(W_EOL) ? "TRUE" : "FALSE ");
273  tprintf(" W_NORMALIZED = %s\n",
274  flags.bit(W_NORMALIZED) ? "TRUE" : "FALSE ");
275  tprintf(" W_SCRIPT_HAS_XHEIGHT = %s\n",
276  flags.bit(W_SCRIPT_HAS_XHEIGHT) ? "TRUE" : "FALSE ");
277  tprintf(" W_SCRIPT_IS_LATIN = %s\n",
278  flags.bit(W_SCRIPT_IS_LATIN) ? "TRUE" : "FALSE ");
279  tprintf(" W_DONT_CHOP = %s\n", flags.bit(W_DONT_CHOP) ? "TRUE" : "FALSE ");
280  tprintf(" W_REP_CHAR = %s\n", flags.bit(W_REP_CHAR) ? "TRUE" : "FALSE ");
281  tprintf(" W_FUZZY_SP = %s\n", flags.bit(W_FUZZY_SP) ? "TRUE" : "FALSE ");
282  tprintf(" W_FUZZY_NON = %s\n", flags.bit(W_FUZZY_NON) ? "TRUE" : "FALSE ");
283  tprintf("Correct= %s\n", correct.string());
284  tprintf("Rejected cblob count = %d\n", rej_cblobs.length());
285  tprintf("Script = %d\n", script_id_);
286 }
void print() const
Definition: rect.h:278
const char * string() const
Definition: strngs.cpp:196
TBOX bounding_box() const
Definition: werd.cpp:159
Definition: werd.h:35
Definition: werd.h:32
bool bit(uint8_t bit_num) const
Definition: bits16.h:57
uint16_t val
Definition: bits16.h:28
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:37
Definition: werd.h:34

◆ rej_cblob_list()

C_BLOB_LIST* WERD::rej_cblob_list ( )
inline

Definition at line 93 of file werd.h.

93  { // compact format
94  return &rej_cblobs;
95  }

◆ restricted_bounding_box()

TBOX WERD::restricted_bounding_box ( bool  upper_dots,
bool  lower_dots 
) const

Definition at line 163 of file werd.cpp.

163  {
164  TBOX box = true_bounding_box();
165  int bottom = box.bottom();
166  int top = box.top();
167  // This is a read-only iteration of the rejected blobs.
168  C_BLOB_IT it(const_cast<C_BLOB_LIST*>(&rej_cblobs));
169  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
170  TBOX dot_box = it.data()->bounding_box();
171  if ((upper_dots || dot_box.bottom() <= top) &&
172  (lower_dots || dot_box.top() >= bottom)) {
173  box += dot_box;
174  }
175  }
176  return box;
177 }
Definition: rect.h:34
int16_t top() const
Definition: rect.h:58
int16_t bottom() const
Definition: rect.h:65
TBOX true_bounding_box() const
Definition: werd.cpp:180

◆ script_id()

int WERD::script_id ( ) const
inline

Definition at line 108 of file werd.h.

108  {
109  return script_id_;
110  }

◆ set_blanks()

void WERD::set_blanks ( uint8_t  new_blanks)
inline

Definition at line 105 of file werd.h.

105  {
106  blanks = new_blanks;
107  }

◆ set_display_flag()

void WERD::set_display_flag ( uint8_t  flag,
bool  value 
)
inline

Definition at line 130 of file werd.h.

130  {
131  disp_flags.set_bit(flag, value);
132  }
bool flag(WERD_FLAGS mask) const
Definition: werd.h:126
void set_bit(uint8_t bit_num, bool value)
Definition: bits16.h:48

◆ set_flag()

void WERD::set_flag ( WERD_FLAGS  mask,
bool  value 
)
inline

Definition at line 127 of file werd.h.

127 { flags.set_bit(mask, value); }
void set_bit(uint8_t bit_num, bool value)
Definition: bits16.h:48

◆ set_script_id()

void WERD::set_script_id ( int  id)
inline

Definition at line 111 of file werd.h.

111  {
112  script_id_ = id;
113  }

◆ set_text()

void WERD::set_text ( const char *  new_text)
inline

Definition at line 124 of file werd.h.

124 { correct = new_text; }

◆ shallow_copy()

WERD * WERD::shallow_copy ( )

WERD::shallow_copy()

Make a shallow copy of a word

Definition at line 351 of file werd.cpp.

351  {
352  WERD *new_word = new WERD;
353 
354  new_word->blanks = blanks;
355  new_word->flags = flags;
356  new_word->dummy = dummy;
357  new_word->correct = correct;
358  return new_word;
359 }
Definition: werd.h:59
WERD()=default

◆ space()

uint8_t WERD::space ( )
inline

Definition at line 102 of file werd.h.

102  { // access function
103  return blanks;
104  }

◆ text()

const char* WERD::text ( ) const
inline

Definition at line 123 of file werd.h.

123 { return correct.string(); }
const char * string() const
Definition: strngs.cpp:196

◆ true_bounding_box()

TBOX WERD::true_bounding_box ( ) const

Definition at line 180 of file werd.cpp.

180  {
181  TBOX box; // box being built
182  // This is a read-only iteration of the good blobs.
183  C_BLOB_IT it(const_cast<C_BLOB_LIST*>(&cblobs));
184  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
185  box += it.data()->bounding_box();
186  }
187  return box;
188 }
Definition: rect.h:34

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