33#define PROGRAM_FEATURE_TYPE "cn"
41static void WriteNormProtos(
const char *Directory,
LIST LabeledProtoList,
44static void WriteProtos(FILE *
File, uint16_t N,
LIST ProtoList,
bool WriteSigProtos,
45 bool WriteInsigProtos);
103int main(
int argc,
char *argv[]) {
104 tesseract::CheckSharedLibraryVersion();
120 for (
const char *PageName = *++argv; PageName !=
nullptr; PageName = *++argv) {
121 printf(
"Reading %s ...\n", PageName);
122 FILE *TrainingPage = fopen(PageName,
"rb");
126 fclose(TrainingPage);
130 printf(
"Clustering ...\n");
134 pCharList = CharList;
137 std::vector<LIST> freeable_protos;
142 if (Clusterer ==
nullptr) {
143 fprintf(stderr,
"Error: nullptr clusterer!\n");
158 "0 significant protos for %s."
159 " Retrying clustering with MinSamples = %f%%\n",
165 freeable_protos.push_back(ProtoList);
170 WriteNormProtos(FLAGS_D.c_str(), NormProtoList, FeatureDefs.
FeatureDesc[desc_index]);
172 for (
auto &freeable_proto : freeable_protos) {
192static void WriteNormProtos(
const char *Directory,
LIST LabeledProtoList,
198 std::string Filename =
"";
199 if (Directory !=
nullptr && Directory[0] !=
'\0') {
200 Filename += Directory;
203 Filename +=
"normproto";
204 printf(
"\nWriting %s ...", Filename.c_str());
205 File = fopen(Filename.c_str(),
"wb");
214 "\nError! Not enough protos for %s: %d protos"
215 " (%d significant protos"
216 ", %d insignificant protos)\n",
221 fprintf(
File,
"\n%s %d\n", LabeledProto->
Label.c_str(), N);
230static void WriteProtos(FILE *
File, uint16_t N,
LIST ProtoList,
bool WriteSigProtos,
231 bool WriteInsigProtos) {
int main(int argc, char *argv[])
#define PROGRAM_FEATURE_TYPE
uint32_t ShortNameToFeatureType(const FEATURE_DEFS_STRUCT &FeatureDefs, const char *ShortName)
void ReadTrainingSamples(const FEATURE_DEFS_STRUCT &feature_definitions, const char *feature_name, int max_samples, UNICHARSET *unicharset, FILE *file, LIST *training_samples)
void WriteParamDesc(FILE *File, uint16_t N, const PARAM_DESC ParamDesc[])
void ParseArguments(int *argc, char ***argv)
void FreeNormProtoList(LIST CharList)
CLUSTERER * SetUpForClustering(const FEATURE_DEFS_STRUCT &FeatureDefs, LABELEDLIST char_sample, const char *program_feature_type)
void AddToNormProtosList(LIST *NormProtoList, LIST ProtoList, const std::string &CharName)
void InitFeatureDefs(FEATURE_DEFS_STRUCT *featuredefs)
void WritePrototype(FILE *File, uint16_t N, PROTOTYPE *Proto)
void FreeProtoList(LIST *ProtoList)
void FreeTrainingSamples(LIST CharList)
void FreeClusterer(CLUSTERER *Clusterer)
int NumberOfProtos(LIST ProtoList, bool CountSigProtos, bool CountInsigProtos)
LIST ClusterSamples(CLUSTERER *Clusterer, CLUSTERCONFIG *Config)
const FEATURE_DESC_STRUCT * FeatureDesc[NUM_FEATURE_TYPES]
const PARAM_DESC * ParamDesc