/usr/include/tesseract/classifier_base.h is in libtesseract-dev 3.02.01-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | /**********************************************************************
* File: classifier_base.h
* Description: Declaration of the Base Character Classifier
* Author: Ahmad Abdulkader
* Created: 2007
*
* (C) Copyright 2008, Google Inc.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*
**********************************************************************/
// The CharClassifier class is the abstract class for any character/grapheme
// classifier.
#ifndef CHAR_CLASSIFIER_BASE_H
#define CHAR_CLASSIFIER_BASE_H
#include <string>
#include "char_samp.h"
#include "char_altlist.h"
#include "char_set.h"
#include "feature_base.h"
#include "lang_model.h"
#include "tuning_params.h"
namespace tesseract {
class CharClassifier {
public:
CharClassifier(CharSet *char_set, TuningParams *params,
FeatureBase *feat_extract) {
char_set_ = char_set;
params_ = params;
feat_extract_ = feat_extract;
fold_sets_ = NULL;
fold_set_cnt_ = 0;
fold_set_len_ = NULL;
init_ = false;
case_sensitive_ = true;
}
virtual ~CharClassifier() {
if (fold_sets_ != NULL) {
for (int fold_set = 0; fold_set < fold_set_cnt_; fold_set++) {
if (fold_sets_[fold_set] != NULL) {
delete []fold_sets_[fold_set];
}
}
delete []fold_sets_;
fold_sets_ = NULL;
}
if (fold_set_len_ != NULL) {
delete []fold_set_len_;
fold_set_len_ = NULL;
}
if (feat_extract_ != NULL) {
delete feat_extract_;
feat_extract_ = NULL;
}
}
// pure virtual functions that need to be implemented by any inheriting class
virtual CharAltList * Classify(CharSamp *char_samp) = 0;
virtual int CharCost(CharSamp *char_samp) = 0;
virtual bool Train(CharSamp *char_samp, int ClassID) = 0;
virtual bool SetLearnParam(char *var_name, float val) = 0;
virtual bool Init(const string &data_file_path, const string &lang,
LangModel *lang_mod) = 0;
// accessors
FeatureBase *FeatureExtractor() {return feat_extract_;}
inline bool CaseSensitive() const { return case_sensitive_; }
inline void SetCaseSensitive(bool case_sensitive) {
case_sensitive_ = case_sensitive;
}
protected:
virtual void Fold() = 0;
virtual bool LoadFoldingSets(const string &data_file_path,
const string &lang,
LangModel *lang_mod) = 0;
FeatureBase *feat_extract_;
CharSet *char_set_;
TuningParams *params_;
int **fold_sets_;
int *fold_set_len_;
int fold_set_cnt_;
bool init_;
bool case_sensitive_;
};
} // tesseract
#endif // CHAR_CLASSIFIER_BASE_H
|