Features.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _CFEATURES__H__
00014 #define _CFEATURES__H__
00015
00016 #include "lib/common.h"
00017 #include "base/SGObject.h"
00018
00020 enum EFeatureType
00021 {
00022 F_UNKNOWN = 0,
00023 F_BOOL = 5,
00024 F_CHAR = 10,
00025 F_BYTE = 20,
00026 F_SHORT = 30,
00027 F_WORD = 40,
00028 F_INT = 50,
00029 F_UINT = 60,
00030 F_LONG = 70,
00031 F_ULONG = 80,
00032 F_SHORTREAL = 90,
00033 F_DREAL = 100,
00034 F_LONGREAL = 110,
00035 F_ANY = 1000
00036 };
00037
00039 enum EFeatureClass
00040 {
00041 C_UNKNOWN = 0,
00042 C_SIMPLE = 10,
00043 C_SPARSE = 20,
00044 C_STRING = 30,
00045 C_COMBINED = 40,
00046 C_MINDYGRAM = 50,
00047 C_COMBINED_DOT = 60,
00048 C_WD = 70,
00049 C_SPEC = 80,
00050 C_WEIGHTEDSPEC = 90,
00051 C_ANY = 1000
00052 };
00053
00055 enum EFeatureProperty
00056 {
00057 FP_NONE = 0,
00058 FP_DOT = 1
00059 };
00060
00061
00062 #include "preproc/PreProc.h"
00063 class CPreProc;
00064 class CFeatures;
00065
00066
00086 class CFeatures : public CSGObject
00087 {
00088 public:
00093 CFeatures(int32_t size=0);
00094
00096 CFeatures(const CFeatures& orig);
00097
00102 CFeatures(char* fname);
00103
00110 virtual CFeatures* duplicate() const=0 ;
00111
00112 virtual ~CFeatures();
00113
00120 virtual EFeatureType get_feature_type()=0;
00121
00128 virtual EFeatureClass get_feature_class()=0;
00129
00135 virtual int32_t add_preproc(CPreProc* p);
00136
00142 virtual CPreProc* del_preproc(int32_t num);
00143
00148 CPreProc* get_preproc(int32_t num);
00149
00154 inline void set_preprocessed(int32_t num) { preprocessed[num]=true; }
00155
00160 inline bool is_preprocessed(int32_t num) { return preprocessed[num]; }
00161
00166 int32_t get_num_preprocessed();
00167
00172 inline int32_t get_num_preproc() { return num_preproc; }
00173
00175 void clean_preprocs();
00176
00181 inline int32_t get_cache_size() { return cache_size; };
00182
00189 virtual int32_t get_num_vectors()=0 ;
00190
00199 virtual bool reshape(int32_t num_features, int32_t num_vectors) { return false; }
00200
00207 virtual int32_t get_size()=0;
00208
00210 void list_feature_obj();
00211
00217 virtual bool load(char* fname);
00218
00224 virtual bool save(char* fname);
00225
00231 bool check_feature_compatibility(CFeatures* f);
00232
00238 inline bool has_property(EFeatureProperty p) { return (properties & p) != 0; }
00239
00244 inline void set_property(EFeatureProperty p)
00245 {
00246 properties |= p;
00247 }
00248
00253 inline void unset_property(EFeatureProperty p)
00254 {
00255 properties &= (properties | p) ^ p;
00256 }
00257
00258 private:
00260 uint64_t properties;
00261
00263 int32_t cache_size;
00264
00266 CPreProc** preproc;
00267
00269 int32_t num_preproc;
00270
00272 bool* preprocessed;
00273 };
00274 #endif