26 const char *filename) {
27 const int kDictDebugLevel = 1;
29 if (!dawg_file.
Open(filename,
nullptr)) {
30 tprintf(
"Could not open %s for reading.\n", filename);
33 tprintf(
"Loading word list from %s\n", filename);
36 if (!retval->
Load(&dawg_file)) {
37 tprintf(
"Could not read %s\n", filename);
48 void output_word(
const char *word) { fprintf(file_,
"%s\n", word); }
54 static int WriteDawgAsWordlist(
const UNICHARSET &unicharset,
56 const char *outfile_name) {
57 FILE *out = fopen(outfile_name,
"wb");
59 tprintf(
"Could not open %s for writing.\n", outfile_name);
63 using namespace std::placeholders;
69 int main(
int argc,
char *argv[]) {
70 tesseract::CheckSharedLibraryVersion();
72 if (argc > 1 && (!strcmp(argv[1],
"-v") || !strcmp(argv[1],
"--version"))) {
75 }
else if (argc != 4) {
76 tprintf(
"Print all the words in a given dawg.\n");
77 tprintf(
"Usage: %s -v | --version | %s <unicharset> <dawgfile> <wordlistfile>\n",
81 const char *unicharset_file = argv[1];
82 const char *dawg_file = argv[2];
83 const char *wordlist_file = argv[3];
86 tprintf(
"Error loading unicharset from %s.\n", unicharset_file);
90 if (dict ==
nullptr) {
91 tprintf(
"Error loading dictionary from %s.\n", dawg_file);
94 int retval = WriteDawgAsWordlist(unicharset, dict, wordlist_file);