dict/choices.h File Reference

#include <stdio.h>
#include <string.h>
#include "oldlist.h"

Go to the source code of this file.

Classes

Defines

Typedefs

Functions


Define Documentation

#define best_certainty ( choices   )     (((A_CHOICE*) (first (choices)))->certainty)

Return the certainty of the best choice.

Definition at line 98 of file choices.h.

Referenced by AddLargeSpeckleTo(), evaluate_chunks(), permute_top_choice(), print_choices(), select_blob_to_split(), and UniformCertainties().

#define best_probability ( choices   )     (((A_CHOICE*) (first (choices)))->rating)

Return the probability of the best choice.

Definition at line 92 of file choices.h.

Referenced by AddLargeSpeckleTo(), append_number_choices(), dawg_permute_and_select(), evaluate_chunks(), improve_one_blob(), number_permute_and_select(), permute_top_choice(), print_choices(), rating_priority(), and select_blob_to_split().

#define best_string ( choices   )     (first (choices) ? ((A_CHOICE*) (first (choices)))->string : NULL)

Return the string corresponding to the best choice.

Definition at line 86 of file choices.h.

Referenced by dawg_permute(), permute_subword(), permute_top_choice(), and print_choices().

#define class_certainty ( choice   )     (((A_CHOICE*) (choice))->certainty)

Return the certainty of a given character class.

Definition at line 110 of file choices.h.

Referenced by AcceptableChoice(), AcceptableResult(), add_document_word(), append_next_choice(), append_number_choices(), copy_choices(), good_choice(), LogNewWordChoice(), NewViableChoice(), permute_characters(), permute_compound_words(), permute_subword(), permute_top_choice(), ReplaceDuplicateChoice(), UniformCertainties(), and word_associator().

#define class_config ( choice   )     (((A_CHOICE*) (choice))->config)

Return the config of a given character class.

Definition at line 128 of file choices.h.

Referenced by copy_choices().

#define class_permuter ( choice   )     (((A_CHOICE*) (choice))->permuter)

Return the permuter of a given character class.

Definition at line 122 of file choices.h.

Referenced by adjust_word(), copy_choices(), and permute_top_choice().

#define class_probability ( choice   )     (((A_CHOICE*) (choice))->rating)

Return/set the probability of a given character class.

Definition at line 104 of file choices.h.

Referenced by adjust_non_word(), adjust_number(), adjust_word(), append_next_choice(), append_number_choices(), copy_choices(), dawg_permute_and_select(), evaluate_state(), good_choice(), improve_by_chopping(), LogNewRawChoice(), LogNewWordChoice(), NewViableChoice(), number_permute_and_select(), permute_all(), permute_characters(), permute_compound_words(), permute_subword(), permute_top_choice(), permute_words(), print_matrix(), ReplaceDuplicateChoice(), and word_associator().

#define class_string ( choice   )     (((A_CHOICE*) (choice))->string)

Return the probability of a given character class.

Definition at line 116 of file choices.h.

Referenced by AcceptableChoice(), AcceptableResult(), add_document_word(), adjust_non_word(), adjust_number(), adjust_word(), append_next_choice(), append_number_choices(), cc_recog(), ChoiceSameAs(), chop_word_main(), copy_choices(), NewViableChoice(), permute_all(), permute_characters(), permute_compound_words(), permute_subword(), permute_top_choice(), print_matrix(), and ReplaceDuplicateChoice().

#define clone_choice ( choice_2,
choice_1   ) 

Value:

if (class_string (choice_2)) strfree (class_string (choice_2));    \
class_probability (choice_2) = class_probability (choice_1);       \
class_certainty   (choice_2) = class_certainty   (choice_1);       \
class_permuter    (choice_2) = class_permuter   (choice_1);        \
class_string      (choice_2) = strsave (class_string (choice_1))   \
Copy the contents of this choice record onto another replacing any previous value it might of had.

Definition at line 135 of file choices.h.

Referenced by dawg_permute_and_select(), number_permute_and_select(), permute_characters(), and permute_top_choice().

#define COMPOUND_PERM   9

Definition at line 61 of file choices.h.

#define DOC_DAWG_PERM   6

Definition at line 58 of file choices.h.

#define free_choices (  )     destroy_nodes ((c), free_choice)

Free a list of choices.

Definition at line 146 of file choices.h.

Referenced by free_matrix(), and improve_one_blob().

#define FREQ_DAWG_PERM   8

Definition at line 60 of file choices.h.

#define LOWER_CASE_PERM   2

Definition at line 54 of file choices.h.

#define NO_PERM   0

Definition at line 52 of file choices.h.

#define NUMBER_PERM   4

Definition at line 56 of file choices.h.

#define print_bold ( string   )     cprintf ("\033&dB%s\033&d@", string)

Print a string in bold type by using escape sequences.

This only works for certain output devices.

Definition at line 154 of file choices.h.

Referenced by print_choices().

#define SYSTEM_DAWG_PERM   5

Definition at line 57 of file choices.h.

#define TOP_CHOICE_PERM   1

Definition at line 53 of file choices.h.

#define UPPER_CASE_PERM   3

Definition at line 55 of file choices.h.

#define USER_DAWG_PERM   7

Definition at line 59 of file choices.h.


Typedef Documentation

A_CHOICE

Type of choicestruct, a rating choice for Wise Owl ??

CHOICES

Type of LIST, holds list of choices.

Definition at line 48 of file choices.h.


Function Documentation

CHOICES append_choice ( CHOICES  ratings,
const char *  string,
float  rating,
float  certainty,
INT8  config 
)

Create a new choice record.

Store the string value in a safe place. Add the new choice record to the list. NB - This is only used by matchers, so permuter is always NO_PERM

Date:
SPC 16/9/92

Definition at line 48 of file choices.cpp.

References new_choice(), NO_PERM, and push_last().

Referenced by AdaptiveClassifier(), AddLargeSpeckleTo(), call_matcher(), and ConvertMatchesToChoices().

00052                                    {
00053   A_CHOICE *this_choice;
00054 
00055   this_choice = new_choice (string, rating, certainty, config, NO_PERM);
00056   ratings = push_last (ratings, (LIST) this_choice);
00057   return (ratings);
00058 }

CHOICES copy_choices ( CHOICES  choices  ) 

Copy a list of choices; there will be two copies in memory.

Definition at line 64 of file choices.cpp.

References class_certainty, class_config, class_permuter, class_probability, class_string, first, iterate_list, new_choice(), NIL, push(), and reverse_d().

Referenced by get_match_by_bounds(), and put_match().

00064                                       { 
00065   CHOICES l;
00066   CHOICES result = NIL;
00067 
00068   iterate_list(l, choices) { 
00069     result = push (result,
00070       (LIST) new_choice (class_string (first (l)),
00071       class_probability (first (l)),
00072       class_certainty (first (l)),
00073       class_config (first (l)),
00074       class_permuter (first (l))));
00075   }
00076   return (reverse_d (result));
00077 }

void free_choice ( void *  arg  ) 

Free up the memory taken by one choice rating.

Definition at line 83 of file choices.cpp.

References strfree.

Referenced by append_number_choices(), convert_choice_list(), dawg_permute_and_select(), init_match_table(), number_permute_and_select(), permute_all(), permute_characters(), permute_subword(), and permute_top_choice().

00083                             {  //LIST choice)
00084   A_CHOICE *this_choice;
00085   LIST choice = (LIST) arg;
00086 
00087   this_choice = (A_CHOICE *) choice;
00088   if (this_choice) {
00089     if (this_choice->string)
00090       strfree (this_choice->string);
00091     oldchoice(this_choice); 
00092   }
00093 }

A_CHOICE* new_choice ( const char *  string,
float  rating,
float  certainty,
INT8  config,
char  permuter 
)

Create a new choice record & store the string value in a safe place.

Definition at line 99 of file choices.cpp.

References choicestruct::certainty, choicestruct::config, choicestruct::permuter, choicestruct::rating, choicestruct::string, and strsave.

Referenced by append_choice(), append_next_choice(), append_number_choices(), check_block_occ(), copy_choices(), number_permute_and_select(), permute_compound_words(), permute_top_choice(), and permute_words().

00103                                     {
00104   A_CHOICE *this_choice;
00105 
00106   this_choice = newchoice ();
00107   this_choice->string = strsave (string);
00108   this_choice->rating = rating;
00109   this_choice->certainty = certainty;
00110   this_choice->config = config;
00111   this_choice->permuter = permuter;
00112   return (this_choice);
00113 }

void print_choices ( const char *  label,
CHOICES  rating 
)

Print the probability ratings for a particular blob or word.

Definition at line 119 of file choices.cpp.

References best_certainty, best_probability, best_string, CHARS_PER_LINE, cprintf(), FALSE, iterate, NIL, print_bold, show_bold, and TRUE.

Referenced by dawg_permute(), dawg_permute_and_select(), number_permute(), and number_permute_and_select().

00121                                    {
00122   int first_one = TRUE;
00123   char str[CHARS_PER_LINE];
00124   int len;
00125 
00126   cprintf ("%-20s\n", label);
00127   if (rating == NIL)
00128     cprintf (" No rating ");
00129 
00130   iterate(rating) { 
00131 
00132     if (first_one && show_bold) {
00133       cprintf ("|");
00134       len = sprintf (str, " %s ", best_string (rating));
00135       print_bold(str); 
00136       while (len++ < 8)
00137         cprintf (" ");
00138     }
00139     else {
00140       cprintf ("| %-7s", best_string (rating));
00141     }
00142 
00143     cprintf ("%5.2lf ", best_probability (rating));
00144 
00145     cprintf ("%5.2lf", best_certainty (rating));
00146     first_one = FALSE;
00147   }
00148   cprintf ("\n");
00149 }


Generated on Wed Feb 28 19:49:22 2007 for Tesseract by  doxygen 1.5.1