98 if (ClassId >= NormProtos->NumProtos) {
115 Protos = NormProtos->Protos[ClassId];
118 tprintf(
"\nChar norm for class %s\n", unicharset.id_to_unichar(ClassId));
127 tprintf(
"YMiddle: Proto=%g, Delta=%g, Var=%g, Dist=%g\n",
134 tprintf(
"Height: Proto=%g, Delta=%g, Var=%g, Dist=%g\n",
141 tprintf(
"Width: Proto=%g, Delta=%g, Var=%g\n",
149 tprintf(
"Total Dist=%g, scaled=%g, sigmoid=%g, penalty=%g\n",
154 if (Match < BestMatch)
162 void Classify::FreeNormProtos() {
163 if (NormProtos != NULL) {
164 for (
int i = 0; i < NormProtos->NumProtos; i++)
166 Efree(NormProtos->Protos);
167 Efree(NormProtos->ParamDesc);
188 NormAdj = NormAdj * NormAdj * NormAdj;
190 NormAdj = NormAdj * NormAdj;
193 return (1.0 / (1.0 + NormAdj));
217 for (i = 0, TotalMatch = 0.0; i <
NumParams; i++) {
218 ParamMatch = (Feature->
Params[i] -
Mean(Proto, i)) /
221 fprintf (File,
" %6.1f", ParamMatch);
224 TotalMatch += ParamMatch * ParamMatch;
226 fprintf (File,
" --> %6.1f (%4.2f)\n",
255 NormProtos->
NumProtos = unicharset.size();
257 for (i = 0; i < NormProtos->
NumProtos; i++)
265 const int kMaxLineSize = 100;
266 char line[kMaxLineSize];
267 while (fp->
FGets(line, kMaxLineSize) !=
nullptr) {
268 if (sscanf(line,
"%s %d", unichar, &NumProtos) != 2)
continue;
269 if (unicharset.contains_unichar(unichar)) {
270 unichar_id = unicharset.unichar_to_id(unichar);
271 Protos = NormProtos->
Protos[unichar_id];
276 tprintf(
"Error: unichar %s in normproto file is not in unichar set.\n",
double classify_norm_adj_curl
FLOAT32 StandardDeviation(PROTOTYPE *Proto, uinT16 Dimension)
PROTOTYPE * ReadPrototype(TFile *fp, uinT16 N)
NORM_PROTOS * ReadNormProtos(FILE *File)
LIST push_last(LIST list, void *item)
double NormEvidenceOf(register double NormAdj)
FLOAT32 Mean(PROTOTYPE *Proto, uinT16 Dimension)
#define double_VAR(name, val, comment)
uinT16 ReadSampleSize(TFile *fp)
const double kWidthErrorWeighting
void FreeProtoList(LIST *ProtoList)
double classify_norm_adj_midpoint
void FreePrototype(void *arg)
void PrintNormMatch(FILE *File, int NumParams, PROTOTYPE *Proto, FEATURE Feature)
PARAM_DESC * ReadParamDesc(TFile *fp, uinT16 N)
char * FGets(char *buffer, int buffer_size)