tesseract  4.1.1
dawg2wordlist.cpp File Reference
#include "commontraining.h"
#include "dawg.h"
#include "serialis.h"
#include "tesscallback.h"
#include "trie.h"
#include "unicharset.h"

Go to the source code of this file.

Classes

class  WordOutputter
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 71 of file dawg2wordlist.cpp.

71  {
72  tesseract::CheckSharedLibraryVersion();
73 
74  if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
75  printf("%s\n", tesseract::TessBaseAPI::Version());
76  return 0;
77  } else if (argc != 4) {
78  tprintf("Print all the words in a given dawg.\n");
79  tprintf("Usage: %s -v | --version | %s <unicharset> <dawgfile> <wordlistfile>\n",
80  argv[0], argv[0]);
81  return 1;
82  }
83  const char *unicharset_file = argv[1];
84  const char *dawg_file = argv[2];
85  const char *wordlist_file = argv[3];
86  UNICHARSET unicharset;
87  if (!unicharset.load_from_file(unicharset_file)) {
88  tprintf("Error loading unicharset from %s.\n", unicharset_file);
89  return 1;
90  }
91  tesseract::Dawg *dict = LoadSquishedDawg(unicharset, dawg_file);
92  if (dict == nullptr) {
93  tprintf("Error loading dictionary from %s.\n", dawg_file);
94  return 1;
95  }
96  int retval = WriteDawgAsWordlist(unicharset, dict, wordlist_file);
97  delete dict;
98  return retval;
99 }
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:35
static const char * Version()
Definition: baseapi.cpp:233
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:388