tesseract v5.3.3.20231005
merge_unicharsets.cpp File Reference
#include "commontraining.h"
#include "unicharset.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 22 of file merge_unicharsets.cpp.

22 {
23 tesseract::CheckSharedLibraryVersion();
24
25 if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
26 printf("%s\n", tesseract::TessBaseAPI::Version());
27 return EXIT_SUCCESS;
28 } else if (argc < 4) {
29 // Print usage
30 printf(
31 "Usage: %s -v | --version |\n"
32 " %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
33 argv[0], argv[0]);
34 return EXIT_FAILURE;
35 }
36
37 tesseract::UNICHARSET input_unicharset, result_unicharset;
38 for (int arg = 1; arg < argc - 1; ++arg) {
39 // Load the input unicharset
40 if (input_unicharset.load_from_file(argv[arg])) {
41 printf("Loaded unicharset of size %zu from file %s\n", input_unicharset.size(), argv[arg]);
42 result_unicharset.AppendOtherUnicharset(input_unicharset);
43 } else {
44 printf("Failed to load unicharset from file %s!!\n", argv[arg]);
45 return EXIT_FAILURE;
46 }
47 }
48
49 // Save the combined unicharset.
50 if (result_unicharset.save_to_file(argv[argc - 1])) {
51 printf("Wrote unicharset file %s.\n", argv[argc - 1]);
52 } else {
53 printf("Cannot save unicharset file %s.\n", argv[argc - 1]);
54 return EXIT_FAILURE;
55 }
56 return EXIT_SUCCESS;
57}
static const char * Version()
Definition: baseapi.cpp:241
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:391
bool save_to_file(const char *const filename) const
Definition: unicharset.h:361
size_t size() const
Definition: unicharset.h:355
void AppendOtherUnicharset(const UNICHARSET &src)
Definition: unicharset.cpp:454