33int main(
int argc,
char **argv) {
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))) {
42 "Usage: %s -v | --version |\n"
43 " %s [-t | -r [reverse policy] ] word_list_file"
44 " dawg_file unicharset_file\n",
57 sscanf(argv[++argv_index],
"%d", &tmp_int);
61 const char *wordlist_filename = argv[++argv_index];
62 const char *dawg_filename = argv[++argv_index];
63 const char *unicharset_file = argv[++argv_index];
64 tprintf(
"Loading unicharset from '%s'\n", unicharset_file);
66 tprintf(
"Failed to load unicharset from '%s'\n", unicharset_file);
70 if (argc == 4 || argc == 6) {
74 classify.
getDict().dawg_debug_level);
75 tprintf(
"Reading word list from '%s'\n", wordlist_filename);
77 tprintf(
"Failed to add word list from '%s'\n", wordlist_filename);
80 tprintf(
"Reducing Trie to SquishedDawg\n");
81 std::unique_ptr<tesseract::SquishedDawg> dawg(trie.
trie_to_dawg());
82 if (dawg && dawg->NumEdges() > 0) {
83 tprintf(
"Writing squished DAWG to '%s'\n", dawg_filename);
84 dawg->write_squished_dawg(dawg_filename);
86 tprintf(
"Dawg is empty, skip producing the output file\n");
88 }
else if (argc == 5) {
89 tprintf(
"Loading dawg DAWG from '%s'\n", dawg_filename);
93 classify.
getDict().dawg_debug_level);
94 tprintf(
"Checking word list from '%s'\n", wordlist_filename);
97 tprintf(
"Invalid command-line options\n");
int main(int argc, char **argv)
void tprintf(const char *format,...)
static const char * Version()
bool load_from_file(const char *const filename, bool skip_fragments)
int check_for_words(const char *filename, const UNICHARSET &unicharset, bool enable_wildcard) const
const UNICHARSET & getUnicharset() const
bool read_and_add_word_list(const char *filename, const UNICHARSET &unicharset, Trie::RTLReversePolicy reverse)
SquishedDawg * trie_to_dawg()
static const char * get_reverse_policy_name(RTLReversePolicy reverse_policy)