34 tesseract::CheckSharedLibraryVersion();
36 if (argc > 1 && (!strcmp(argv[1],
"-v") || !strcmp(argv[1],
"--version"))) {
39 }
else if (!(argc == 4 || (argc == 5 && strcmp(argv[1],
"-t") == 0) ||
40 (argc == 6 && strcmp(argv[1],
"-r") == 0))) {
41 printf(
"Usage: %s -v | --version |\n" 42 " %s [-t | -r [reverse policy] ] word_list_file" 43 " dawg_file unicharset_file\n", argv[0], argv[0]);
48 if (argc == 5) ++argv_index;
54 sscanf(argv[++argv_index],
"%d", &tmp_int);
56 tprintf(
"Set reverse_policy to %s\n",
59 if (argc == 7) argv_index += 3;
60 const char* wordlist_filename = argv[++argv_index];
61 const char* dawg_filename = argv[++argv_index];
62 const char* unicharset_file = argv[++argv_index];
63 tprintf(
"Loading unicharset from '%s'\n", unicharset_file);
65 tprintf(
"Failed to load unicharset from '%s'\n", unicharset_file);
70 if (argc == 4 || argc == 6) {
75 tprintf(
"Reading word list from '%s'\n", wordlist_filename);
76 if (!trie.read_and_add_word_list(wordlist_filename, unicharset,
78 tprintf(
"Failed to add word list from '%s'\n", wordlist_filename);
81 tprintf(
"Reducing Trie to SquishedDawg\n");
83 if (dawg !=
nullptr && dawg->
NumEdges() > 0) {
84 tprintf(
"Writing squished DAWG to '%s'\n", dawg_filename);
87 tprintf(
"Dawg is empty, skip producing the output file\n");
90 }
else if (argc == 5) {
91 tprintf(
"Loading dawg DAWG from '%s'\n", dawg_filename);
97 tprintf(
"Checking word list from '%s'\n", wordlist_filename);
98 words.check_for_words(wordlist_filename, unicharset,
true);
100 tprintf(
"Invalid command-line options\n");
static const char * get_reverse_policy_name(RTLReversePolicy reverse_policy)
bool write_squished_dawg(TFile *file)
Writes the squished/reduced Dawg to a file.
DLLSYM void tprintf(const char *format,...)
const UNICHARSET & getUnicharset() const
static const char * Version()
bool load_from_file(const char *const filename, bool skip_fragments)