53 static double NormEvidenceOf(
double NormAdj) {
57 NormAdj = NormAdj * NormAdj * NormAdj;
59 NormAdj = NormAdj * NormAdj;
63 return (1.0 / (1.0 + NormAdj));
94 float Classify::ComputeNormMatch(
CLASS_ID ClassId,
104 if (ClassId >= NormProtos->NumProtos) {
117 return (1.0 - NormEvidenceOf(Match));
121 Protos = NormProtos->Protos[ClassId];
124 tprintf(
"\nChar norm for class %s\n", unicharset.id_to_unichar(ClassId));
133 tprintf(
"YMiddle: Proto=%g, Delta=%g, Var=%g, Dist=%g\n",
140 tprintf(
"Height: Proto=%g, Delta=%g, Var=%g, Dist=%g\n",
147 tprintf(
"Width: Proto=%g, Delta=%g, Var=%g\n",
155 tprintf(
"Total Dist=%g, scaled=%g, sigmoid=%g, penalty=%g\n",
157 NormEvidenceOf(Match), 256 * (1 - NormEvidenceOf(Match)));
160 if (Match < BestMatch)
165 return 1.0 - NormEvidenceOf(BestMatch);
168 void Classify::FreeNormProtos() {
169 if (NormProtos !=
nullptr) {
170 for (
int i = 0; i < NormProtos->NumProtos; i++)
172 Efree(NormProtos->Protos);
173 Efree(NormProtos->ParamDesc);
175 NormProtos =
nullptr;
200 NormProtos->
NumProtos = unicharset.size();
202 for (i = 0; i < NormProtos->
NumProtos; i++)
210 const int kMaxLineSize = 100;
211 char line[kMaxLineSize];
212 while (fp->
FGets(line, kMaxLineSize) !=
nullptr) {
213 std::istringstream stream(line);
218 if (unicharset.contains_unichar(unichar)) {
219 unichar_id = unicharset.unichar_to_id(unichar);
220 Protos = NormProtos->
Protos[unichar_id];
225 tprintf(
"Error: unichar %s in normproto file is not in unichar set.\n",
double classify_norm_adj_midpoint
const double kWidthErrorWeighting
char * FGets(char *buffer, int buffer_size)
#define double_VAR(name, val, comment)
PARAM_DESC * ReadParamDesc(TFile *fp, uint16_t N)
LIST push_last(LIST list, void *item)
void FreePrototype(void *arg)
double classify_norm_adj_curl
DLLSYM void tprintf(const char *format,...)
void FreeProtoList(LIST *ProtoList)
uint16_t ReadSampleSize(TFile *fp)
PROTOTYPE * ReadPrototype(TFile *fp, uint16_t N)