46 char_classifier_ =
NULL;
48 word_size_model_ =
NULL;
50 word_unigrams_ =
NULL;
52 size_normalization_ =
false;
56 if (char_classifier_ !=
NULL) {
57 delete char_classifier_;
58 char_classifier_ =
NULL;
61 if (word_size_model_ !=
NULL) {
62 delete word_size_model_;
63 word_size_model_ =
NULL;
66 if (char_set_ !=
NULL) {
71 if (char_bigrams_ !=
NULL) {
76 if (word_unigrams_ !=
NULL) {
77 delete word_unigrams_;
78 word_unigrams_ =
NULL;
81 if (lang_mod_ !=
NULL) {
86 if (params_ !=
NULL) {
112 tess_unicharset_ = tess_unicharset;
113 string data_file_path;
117 fprintf(stderr,
"Unable to get data file path\n");
127 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to load "
132 string lm_file_name = data_file_path + lang_ +
".cube.lm";
135 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to read cube "
136 "language model params from %s\n", lm_file_name.c_str());
139 lang_mod_ =
new TessLangModel(lm_params, data_file_path,
141 tessdata_manager,
this);
142 if (lang_mod_ ==
NULL) {
143 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to create "
160 if (params_ ==
NULL) {
161 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to read "
162 "CubeTuningParams from %s\n", data_file_path.c_str());
168 lang_mod_, char_set_,
170 if (char_classifier_ ==
NULL) {
171 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Load): unable to load "
172 "CharClassifierFactory object from %s\n", data_file_path.c_str());
188 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Create): unable to create "
189 "CubeRecoContext object\n");
193 if (cntxt->Load(tessdata_manager, tess_unicharset) ==
false) {
194 fprintf(stderr,
"Cube ERROR (CubeRecoContext::Create): unable to init "
195 "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)