tesseract  5.0.0
dawg2wordlist.cpp File Reference
#include "commontraining.h"
#include "dawg.h"
#include "trie.h"
#include "unicharset.h"
#include "serialis.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(
80  "Usage: %s -v | --version | %s <unicharset> <dawgfile> "
81  "<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  auto 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.get(), wordlist_file);
99  return retval;
100 }
void tprintf(const char *format,...)
Definition: tprintf.cpp:41
static const char * Version()
Definition: baseapi.cpp:238
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:391