tesseract  4.00.00dev
WERD Class Reference

#include <werd.h>

Inheritance diagram for WERD:
ELIST2_LINK

Public Member Functions

 WERD ()
 
 WERD (C_BLOB_LIST *blob_list, uinT8 blanks, const char *text)
 
 WERD (C_BLOB_LIST *blob_list, WERD *clone)
 
WERDConstructFromSingleBlob (bool bol, bool eol, C_BLOB *blob)
 
 ~WERD ()
 
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 space ()
 
void set_blanks (uinT8 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)
 
BOOL8 flag (WERD_FLAGS mask) const
 
void set_flag (WERD_FLAGS mask, BOOL8 value)
 
BOOL8 display_flag (uinT8 flag) const
 
void set_display_flag (uinT8 flag, BOOL8 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 60 of file werd.h.

Constructor & Destructor Documentation

◆ WERD() [1/3]

WERD::WERD ( )
inline

Definition at line 62 of file werd.h.

62 {}

◆ WERD() [2/3]

WERD::WERD ( C_BLOB_LIST *  blob_list,
uinT8  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 48 of file werd.cpp.

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

◆ 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 119 of file werd.cpp.

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

◆ ~WERD()

WERD::~WERD ( )
inline

Definition at line 78 of file werd.h.

78  {
79  }

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 548 of file werd.cpp.

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

◆ 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 NULL, 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 160 of file werd.cpp.

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

◆ cblob_list()

C_BLOB_LIST* WERD::cblob_list ( )
inline

Definition at line 100 of file werd.h.

100  { // get compact blobs
101  return &cblobs;
102  }

◆ CleanNoise()

void WERD::CleanNoise ( float  size_threshold)

Definition at line 506 of file werd.cpp.

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

◆ ConstructFromSingleBlob()

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

Definition at line 137 of file werd.cpp.

137  {
138  C_BLOB_LIST temp_blobs;
139  C_BLOB_IT temp_it(&temp_blobs);
140  temp_it.add_after_then_move(blob);
141  WERD* blob_word = new WERD(&temp_blobs, this);
142  blob_word->set_flag(W_BOL, bol);
143  blob_word->set_flag(W_EOL, eol);
144  return blob_word;
145 }
Definition: werd.h:36
void set_flag(WERD_FLAGS mask, BOOL8 value)
Definition: werd.h:129
Definition: werd.h:35
Definition: werd.h:60
WERD()
Definition: werd.h:62

◆ 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 NULL 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 412 of file werd.cpp.

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

◆ copy_on()

void WERD::copy_on ( WERD other)

WERD::copy_on

Copy blobs from other word onto this one.

Definition at line 234 of file werd.cpp.

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

◆ display_flag()

BOOL8 WERD::display_flag ( uinT8  flag) const
inline

Definition at line 131 of file werd.h.

131 { return disp_flags.bit(flag); }
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128
BOOL8 bit(uinT8 bit_num) const
Definition: bits16.h:56

◆ flag()

BOOL8 WERD::flag ( WERD_FLAGS  mask) const
inline

Definition at line 128 of file werd.h.

128 { return flags.bit(mask); }
BOOL8 bit(uinT8 bit_num) const
Definition: bits16.h:56

◆ GetNoiseOutlines()

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

Definition at line 530 of file werd.cpp.

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

◆ join_on()

void WERD::join_on ( WERD other)

WERD::join_on

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

Definition at line 211 of file werd.cpp.

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

◆ move()

void WERD::move ( const ICOORD  vec)

WERD::move

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

Definition at line 198 of file werd.cpp.

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

◆ NextColor()

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

Definition at line 306 of file werd.cpp.

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

◆ operator=()

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

WERD::operator=

Assign a word, DEEP copying the blob list

Definition at line 369 of file werd.cpp.

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

◆ plot() [1/2]

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

WERD::plot

Draw the WERD in the given colour.

Definition at line 297 of file werd.cpp.

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

◆ plot() [2/2]

void WERD::plot ( ScrollView window)

WERD::plot

Draw the WERD in rainbow colours in window.

Definition at line 319 of file werd.cpp.

319  {
321  C_BLOB_IT it = &cblobs;
322  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
323  it.data()->plot(window, colour, CHILD_COLOUR);
324  colour = NextColor(colour);
325  }
326  plot_rej_blobs(window);
327 }
static ScrollView::Color NextColor(ScrollView::Color colour)
Definition: werd.cpp:306
#define CHILD_COLOUR
Definition: werd.cpp:32
#define FIRST_COLOUR
Definition: werd.cpp:30
void plot_rej_blobs(ScrollView *window)
Definition: werd.cpp:337

◆ 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 337 of file werd.cpp.

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

◆ print()

void WERD::print ( )

WERD::print

Display members

Definition at line 266 of file werd.cpp.

266  {
267  tprintf("Blanks= %d\n", blanks);
268  bounding_box().print();
269  tprintf("Flags = %d = 0%o\n", flags.val, flags.val);
270  tprintf(" W_SEGMENTED = %s\n", flags.bit(W_SEGMENTED) ? "TRUE" : "FALSE ");
271  tprintf(" W_ITALIC = %s\n", flags.bit(W_ITALIC) ? "TRUE" : "FALSE ");
272  tprintf(" W_BOL = %s\n", flags.bit(W_BOL) ? "TRUE" : "FALSE ");
273  tprintf(" W_EOL = %s\n", flags.bit(W_EOL) ? "TRUE" : "FALSE ");
274  tprintf(" W_NORMALIZED = %s\n",
275  flags.bit(W_NORMALIZED) ? "TRUE" : "FALSE ");
276  tprintf(" W_SCRIPT_HAS_XHEIGHT = %s\n",
277  flags.bit(W_SCRIPT_HAS_XHEIGHT) ? "TRUE" : "FALSE ");
278  tprintf(" W_SCRIPT_IS_LATIN = %s\n",
279  flags.bit(W_SCRIPT_IS_LATIN) ? "TRUE" : "FALSE ");
280  tprintf(" W_DONT_CHOP = %s\n", flags.bit(W_DONT_CHOP) ? "TRUE" : "FALSE ");
281  tprintf(" W_REP_CHAR = %s\n", flags.bit(W_REP_CHAR) ? "TRUE" : "FALSE ");
282  tprintf(" W_FUZZY_SP = %s\n", flags.bit(W_FUZZY_SP) ? "TRUE" : "FALSE ");
283  tprintf(" W_FUZZY_NON = %s\n", flags.bit(W_FUZZY_NON) ? "TRUE" : "FALSE ");
284  tprintf("Correct= %s\n", correct.string());
285  tprintf("Rejected cblob count = %d\n", rej_cblobs.length());
286  tprintf("Script = %d\n", script_id_);
287 }
Definition: werd.h:36
uinT16 val
Definition: bits16.h:28
#define tprintf(...)
Definition: tprintf.h:31
const char * string() const
Definition: strngs.cpp:198
Definition: werd.h:33
TBOX bounding_box() const
Definition: werd.cpp:160
Definition: werd.h:35
void print() const
Definition: rect.h:270
BOOL8 bit(uinT8 bit_num) const
Definition: bits16.h:56

◆ rej_cblob_list()

C_BLOB_LIST* WERD::rej_cblob_list ( )
inline

Definition at line 95 of file werd.h.

95  { // compact format
96  return &rej_cblobs;
97  }

◆ restricted_bounding_box()

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

Definition at line 164 of file werd.cpp.

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

◆ script_id()

int WERD::script_id ( ) const
inline

Definition at line 110 of file werd.h.

110  {
111  return script_id_;
112  }

◆ set_blanks()

void WERD::set_blanks ( uinT8  new_blanks)
inline

Definition at line 107 of file werd.h.

107  {
108  blanks = new_blanks;
109  }

◆ set_display_flag()

void WERD::set_display_flag ( uinT8  flag,
BOOL8  value 
)
inline

Definition at line 132 of file werd.h.

132  {
133  disp_flags.set_bit(flag, value);
134  }
void set_bit(uinT8 bit_num, BOOL8 value)
Definition: bits16.h:47
BOOL8 flag(WERD_FLAGS mask) const
Definition: werd.h:128

◆ set_flag()

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

Definition at line 129 of file werd.h.

129 { flags.set_bit(mask, value); }
void set_bit(uinT8 bit_num, BOOL8 value)
Definition: bits16.h:47

◆ set_script_id()

void WERD::set_script_id ( int  id)
inline

Definition at line 113 of file werd.h.

113  {
114  script_id_ = id;
115  }

◆ set_text()

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

Definition at line 126 of file werd.h.

126 { correct = new_text; }

◆ shallow_copy()

WERD * WERD::shallow_copy ( )

WERD::shallow_copy()

Make a shallow copy of a word

Definition at line 352 of file werd.cpp.

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

◆ space()

uinT8 WERD::space ( )
inline

Definition at line 104 of file werd.h.

104  { // access function
105  return blanks;
106  }

◆ text()

const char* WERD::text ( ) const
inline

Definition at line 125 of file werd.h.

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

◆ true_bounding_box()

TBOX WERD::true_bounding_box ( ) const

Definition at line 181 of file werd.cpp.

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

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