48 char_classifier_ =
NULL;
50 word_size_model_ =
NULL;
52 word_unigrams_ =
NULL;
54 size_normalization_ =
false;
58 if (char_classifier_ !=
NULL) {
59 delete char_classifier_;
60 char_classifier_ =
NULL;
63 if (word_size_model_ !=
NULL) {
64 delete word_size_model_;
65 word_size_model_ =
NULL;
68 if (char_set_ !=
NULL) {
73 if (char_bigrams_ !=
NULL) {
78 if (word_unigrams_ !=
NULL) {
79 delete word_unigrams_;
80 word_unigrams_ =
NULL;
83 if (lang_mod_ !=
NULL) {
88 if (params_ !=
NULL) {
118 tess_unicharset_ = tess_unicharset;
119 string data_file_path;
123 fprintf(stderr,
"Unable to get data file path\n");
133 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to load "
138 string lm_file_name = data_file_path + lang_ +
".cube.lm";
141 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to read cube "
142 "language model params from %s\n", lm_file_name.c_str());
145 lang_mod_ =
new TessLangModel(lm_params, data_file_path,
147 tessdata_manager,
this);
148 if (lang_mod_ ==
NULL) {
149 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to create "
166 if (params_ ==
NULL) {
167 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to read "
168 "CubeTuningParams from %s\n", data_file_path.c_str());
174 lang_mod_, char_set_,
176 if (char_classifier_ ==
NULL) {
177 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to load "
178 "CharClassifierFactory object from %s\n", data_file_path.c_str());
194 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Create): unable to create "
195 "CubeRecoContext object\n");
199 if (cntxt->Load(tessdata_manager, tess_unicharset) ==
false) {
200 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Create): unable to init "
201 "CubeRecoContext object\n");
static bool ReadFileToString(const string &file_name, string *str)
static CharBigrams * Create(const string &data_file_path, const string &lang)
CubeRecoContext(Tesseract *tess_obj)
static WordUnigrams * Create(const string &data_file_path, const string &lang)
static WordSizeModel * Create(const string &data_file_path, const string &lang, CharSet *char_set, bool contextual)
static CharClassifier * Create(const string &data_file_path, const string &lang, LangModel *lang_mod, CharSet *char_set, TuningParams *params)
static CubeRecoContext * Create(Tesseract *tess_obj, TessdataManager *tessdata_manager, UNICHARSET *tess_unicharset)
static CharSet * Create(TessdataManager *tessdata_manager, UNICHARSET *tess_unicharset)
const char * string() const
bool GetDataFilePath(string *path) const
static CubeTuningParams * Create(const string &data_file, const string &lang)