tesseract  4.0.0-1-g2a2b
dawg2wordlist.cpp File Reference
#include "commontraining.h"
#include "dawg.h"
#include "host.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 73 of file dawg2wordlist.cpp.

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