tesseract  5.0.0-alpha-619-ge9db
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 23 of file merge_unicharsets.cpp.

23  {
24  tesseract::CheckSharedLibraryVersion();
25 
26  if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
27  printf("%s\n", tesseract::TessBaseAPI::Version());
28  return 0;
29  } else if (argc < 4) {
30  // Print usage
31  printf("Usage: %s -v | --version |\n"
32  " %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
33  argv[0], argv[0]);
34  return 1;
35  }
36 
37  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 %d from file %s\n",
42  input_unicharset.size(), argv[arg]);
43  result_unicharset.AppendOtherUnicharset(input_unicharset);
44  } else {
45  printf("Failed to load unicharset from file %s!!\n", argv[arg]);
46  exit(1);
47  }
48  }
49 
50  // Save the combined unicharset.
51  if (result_unicharset.save_to_file(argv[argc - 1])) {
52  printf("Wrote unicharset file %s.\n", argv[argc - 1]);
53  } else {
54  printf("Cannot save unicharset file %s.\n", argv[argc - 1]);
55  exit(1);
56  }
57  return 0;
58 }
UNICHARSET::load_from_file
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:378
UNICHARSET::AppendOtherUnicharset
void AppendOtherUnicharset(const UNICHARSET &src)
Definition: unicharset.cpp:463
UNICHARSET::save_to_file
bool save_to_file(const char *const filename) const
Definition: unicharset.h:350
UNICHARSET
Definition: unicharset.h:145
tesseract::TessBaseAPI::Version
static const char * Version()
Definition: baseapi.cpp:233
UNICHARSET::size
int size() const
Definition: unicharset.h:341