📄 decisiontreebase.h
字号:
// file: $isip/class/pr/DecisionTreeBase/DecisionTreeBase.h// version: $Id: DecisionTreeBase.h,v 1.4 2002/12/05 22:19:13 parihar Exp $//// make sure definitions are only made once://#ifndef ISIP_DECISION_TREE_BASE#define ISIP_DECISION_TREE_BASE// isip include files//#ifndef ISIP_BI_GRAPH#include <BiGraph.h>#endif#ifndef ISIP_DEBUG_LEVEL#include <DebugLevel.h>#endif#ifndef ISIP_FILENAME#include <Filename.h>#endif// DecisionTreeBase: a class that defines an interface contract for all// the DecisionTrees//template<class TObject>class DecisionTreeBase : public BiGraph<TObject> { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define an enumeration for all possible stopping rules for splitting: // enum STOPMODE { PURE = 0, THRESH, DEPTH, DEF_STOPMODE = PURE }; // define an enumeration for run mode // enum RUNMODE { TRAIN = 0, TEST, DEF_RUNMODE = TRAIN }; // define static NameMap objects // static const NameMap STOPMODE_MAP; static const NameMap RUNMODE_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String PARAM_STOPMODE; static const String PARAM_RUNMODE; static const String PARAM_DBGL; //---------------------------------------- // // default values and arguments // //---------------------------------------- // signal processing constants // static const long DEF_DEPTH = 0; //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = 00100200; //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: // data structure declarations // typedef Pair<String, SingleLinkedList<String> > Attribute; typedef SingleLinkedList<Attribute> Attributes; // stopmode type // STOPMODE stopmode_d; // runmode type // RUNMODE runmode_d; // define parameters that are not part of the i/o for the class // long depth_d; // Atributes of the data // Attributes attributes_d; // debugging parameters // DebugLevel debug_level_d; //--------------------------------------------------------------------------- // // required public methods // //---------------------------------------------------------------------------public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // diagnose method is moved outside the class header file and // defined in the DecisionTreeBaseDiagnose.h in order to avoid issues // related to preprocessing of the diagnose code. // // method: setDebug // // note that this method is not virtual since // it operates on protected data found in this class. // boolean setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // other debug methods // virtual boolean debug(const unichar* msg) const; // method: destructor // virtual ~DecisionTreeBase() {} // method: default constructor // DecisionTreeBase(); // method: copy constructor // DecisionTreeBase(const DecisionTreeBase& arg) { assign(arg); } // assign methods: // note that this method is not set to zero. this class must supply // a version of this method, since it manipulates protected data. // virtual boolean assign(const DecisionTreeBase& arg); // method: sofSize // virtual long sofSize() const = 0; // method: read // virtual boolean read(Sof& sof, long tag, const String& name) = 0; // method: write // virtual boolean write(Sof& sof, long tag, const String& name) const = 0; // method: readData // virtual boolean readData(Sof& sof, const String& pname, long size, boolean param, boolean nested) = 0; // method: writeData // virtual boolean writeData(Sof& sof, const String& pname) const = 0; // method: eq // virtual boolean eq(const DecisionTreeBase& arg) const; // memory management methods: // new and delete methods are omitted since only the derived // classes will be used // virtual boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // // note: these functions are needed to manipulate protected data for // this class that must be invoked by the public interface for the // class. note that the set methods are virtual so a derived class // can override it if it needs to do more with the method, such as // buffer resizing. // //-------------------------------------------------------------------------- // method: setStopMode // boolean setStopMode(STOPMODE stopmode) { stopmode_d = stopmode; return true; } // method: setRunMode // boolean setRunMode(RUNMODE runmode) { runmode_d = runmode; return true; } // method: setDepth // boolean setDepth(long& depth) { depth_d = depth; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getStopMode // STOPMODE getStopMode() const { return stopmode_d; } // method: getRunMode // RUNMODE getRunMode() const { return runmode_d; } // method: getDepth // long getDepth() { return depth_d; } // method: getLeafNodes // boolean getLeafNodes(BiGraphVertex<TObject>& node, SingleLinkedList<BiGraphVertex<TObject> >& leaf_nodes); //--------------------------------------------------------------------------- // // class-specific public methods: // interface contract methods // // note: the methods below constitute the interface required by all // DecisionTrees that are going to be part of the generalized transform // software (PhoneticDecisionTree etc.). // //--------------------------------------------------------------------------- // method: runDecisionTree // virtual boolean runDecisionTree() = 0; // method: setParser // virtual boolean setParser(SofParser* parser) { return false; } //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private:};//---------------------------------------------------------------------------//// we define non-integral constants at the end of class definition for// templates (for non-templates these are defined in the default constructor)// //---------------------------------------------------------------------------// constants: class name//template<class TObject>const String DecisionTreeBase<TObject>::CLASS_NAME(L"DecisionTreeBase");// constants: i/o related constants//template<class TObject>const String DecisionTreeBase<TObject>::PARAM_DBGL(L"debug_level");template<class TObject>const String DecisionTreeBase<TObject>::PARAM_STOPMODE(L"stopmode");template<class TObject>const String DecisionTreeBase<TObject>::PARAM_RUNMODE(L"runmode");// constants: name map for enum//template<class TObject>const NameMap DecisionTreeBase<TObject>::STOPMODE_MAP(L"PURE, THRESH, DEPTH");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -