dict/choices.h

Go to the documentation of this file.
00001 
00033 #ifndef CHOICES_H
00034 #define CHOICES_H
00035 
00036 #include <stdio.h>
00037 #include <string.h>
00038 
00039 #include "oldlist.h"
00040 
00041 /*----------------------------------------------------------------------
00042                 T y p e s
00043 ----------------------------------------------------------------------*/
00048 typedef LIST CHOICES;
00049 
00050 /* Permuter codes used in A_CHOICEs for words */
00051 
00052 #define NO_PERM       0
00053 #define TOP_CHOICE_PERM  1
00054 #define LOWER_CASE_PERM  2
00055 #define UPPER_CASE_PERM  3
00056 #define NUMBER_PERM      4
00057 #define SYSTEM_DAWG_PERM 5
00058 #define DOC_DAWG_PERM    6
00059 #define USER_DAWG_PERM   7
00060 #define FREQ_DAWG_PERM   8
00061 #define COMPOUND_PERM    9
00062 
00071 typedef struct choicestruct
00072 {
00073   float rating;
00074   float certainty;
00075   char permuter;
00076   INT8 config;
00077   char *string;
00078 } A_CHOICE;
00079 
00080 /*----------------------------------------------------------------------
00081                 M a c r o s
00082 ----------------------------------------------------------------------*/
00086 #define best_string(choices)  \
00087 (first (choices) ? ((A_CHOICE*) (first (choices)))->string : NULL)
00088 
00092 #define best_probability(choices)  \
00093 (((A_CHOICE*) (first (choices)))->rating)
00094 
00098 #define best_certainty(choices)  \
00099 (((A_CHOICE*) (first (choices)))->certainty)
00100 
00104 #define class_probability(choice)  \
00105 (((A_CHOICE*) (choice))->rating)
00106 
00110 #define class_certainty(choice)  \
00111 (((A_CHOICE*) (choice))->certainty)
00112 
00116 #define class_string(choice)  \
00117 (((A_CHOICE*) (choice))->string)
00118 
00122 #define class_permuter(choice)  \
00123 (((A_CHOICE*) (choice))->permuter)
00124 
00128 #define class_config(choice)  \
00129 (((A_CHOICE*) (choice))->config)
00130 
00135 #define clone_choice(choice_2,choice_1)  \
00136 if (class_string (choice_2)) strfree (class_string (choice_2));    \
00137 class_probability (choice_2) = class_probability (choice_1);       \
00138 class_certainty   (choice_2) = class_certainty   (choice_1);       \
00139 class_permuter    (choice_2) = class_permuter   (choice_1);        \
00140 class_string      (choice_2) = strsave (class_string (choice_1))   \
00141 
00142 
00146 #define free_choices(c)  \
00147 destroy_nodes ((c), free_choice)
00148 
00154 #define print_bold(string)               \
00155    cprintf ("\033&dB%s\033&d@", string)

/*----------------------------------------------------------------------
              F u n c t i o n s
----------------------------------------------------------------------*/
CHOICES append_choice(CHOICES ratings,
                      const char *string,
                      float rating,
                      float certainty,
                      INT8 config);

CHOICES copy_choices(CHOICES choices); 

void free_choice(void *arg);  //LIST choice);

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

void print_choices(const char *label, CHOICES rating); 
#endif

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