66 int main(
int argc,
char **argv) {
69 printf(
"Combining tessdata files\n");
71 char*
last = &argv[1][strlen(argv[1])-1];
75 output_file += kTrainedDataSuffix;
78 printf(
"Error combining tessdata files into %s\n",
81 printf(
"Output %s created sucessfully.\n", output_file.
string());
83 }
else if (argc >= 4 && (strcmp(argv[1],
"-e") == 0 ||
84 strcmp(argv[1],
"-u") == 0)) {
88 printf(
"Extracting tessdata components from %s\n", argv[2]);
89 if (strcmp(argv[1],
"-e") == 0) {
90 for (i = 3; i < argc; ++i) {
92 printf(
"Wrote %s\n", argv[i]);
94 printf(
"Not extracting %s, since this component"
95 " is not present\n", argv[i]);
101 char*
last = &argv[3][strlen(argv[3])-1];
104 filename += tesseract::kTessdataFileSuffixes[i];
106 printf(
"Wrote %s\n", filename.
string());
111 }
else if (argc >= 4 && strcmp(argv[1],
"-o") == 0) {
113 const char *new_traineddata_filename = argv[2];
114 STRING traineddata_filename = new_traineddata_filename;
115 traineddata_filename +=
".__tmp__";
116 if (rename(new_traineddata_filename, traineddata_filename.
string()) != 0) {
117 tprintf(
"Failed to create a temporary file %s\n",
118 traineddata_filename.
string());
130 printf(
"Usage for combining tessdata components:\n"
131 " %s language_data_path_prefix\n"
132 " (e.g. %s tessdata/eng.)\n\n", argv[0], argv[0]);
133 printf(
"Usage for extracting tessdata components:\n"
134 " %s -e traineddata_file [output_component_file...]\n"
135 " (e.g. %s -e eng.traineddata eng.unicharset)\n\n",
137 printf(
"Usage for overwriting tessdata components:\n"
138 " %s -o traineddata_file [input_component_file...]\n"
139 " (e.g. %s -o eng.traineddata eng.unicharset)\n\n",
141 printf(
"Usage for unpacking all tessdata components:\n"
142 " %s -u traineddata_file output_path_prefix\n"
143 " (e.g. %s -u eng.traineddata tmp/eng.)\n", argv[0], argv[0]);
int main(int argc, char **argv)
bool OverwriteComponents(const char *new_traineddata_filename, char **component_filenames, int num_new_components)
bool ExtractToFile(const char *filename)
static bool CombineDataFiles(const char *language_data_path_prefix, const char *output_filename)
bool Init(const char *data_file_name, int debug_level)
const char * string() const