tesseract  5.0.0-alpha-619-ge9db
dawg2wordlist.cpp File Reference
#include "commontraining.h"
#include "dawg.h"
#include <tesseract/serialis.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 69 of file dawg2wordlist.cpp.

69  {
70  tesseract::CheckSharedLibraryVersion();
71 
72  if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
73  printf("%s\n", tesseract::TessBaseAPI::Version());
74  return 0;
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",
78  argv[0], argv[0]);
79  return 1;
80  }
81  const char *unicharset_file = argv[1];
82  const char *dawg_file = argv[2];
83  const char *wordlist_file = argv[3];
84  UNICHARSET unicharset;
85  if (!unicharset.load_from_file(unicharset_file)) {
86  tprintf("Error loading unicharset from %s.\n", unicharset_file);
87  return 1;
88  }
89  tesseract::Dawg *dict = LoadSquishedDawg(unicharset, dawg_file);
90  if (dict == nullptr) {
91  tprintf("Error loading dictionary from %s.\n", dawg_file);
92  return 1;
93  }
94  int retval = WriteDawgAsWordlist(unicharset, dict, wordlist_file);
95  delete dict;
96  return retval;
97 }
UNICHARSET::load_from_file
bool load_from_file(const char *const filename, bool skip_fragments)
Definition: unicharset.h:378
UNICHARSET
Definition: unicharset.h:145
tesseract::TessBaseAPI::Version
static const char * Version()
Definition: baseapi.cpp:233
tesseract::Dawg
Definition: dawg.h:113
tprintf
DLLSYM void tprintf(const char *format,...)
Definition: tprintf.cpp:34