// file: $isip/class/search/SearchNode/SearchNode.h // // make sure definitions are only made once // #ifndef ISIP_SEARCH_NODE #define ISIP_SEARCH_NODE #ifndef ISIP_LONG #include #endif #ifndef ISIP_VECTOR_DOUBLE #include #endif #ifndef ISIP_DOUBLE_LINKED_LIST #include #endif #ifndef ISIP_STATISTICAL_MODEL #include #endif #ifndef ISIP_SEARCH_SYMBOL #include #endif #ifndef ISIP_INSTANCE #include #endif #ifndef ISIP_TRACE #include #endif // forward class definition(s): // class SearchLevel; class LexicalTree; class Instance; class Trace; // SearchNode: A class to specify a location in a search space. // class SearchNode { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default symbol id // static const int32 DEF_SYMBOL_ID = -1; // define the default model id // static const int32 DEF_MODEL_ID = -1; // define the default dummy symbol id // static const int32 DEF_DUMMY_SYMBOL_ID = -100; // define the default time stamp // static const int32 DEF_TIMESTAMP = -1; // define the inactive likelihood score // static const float32 INACTIVE_SCORE = -11111111111111.0f; //--------------------------------------- // // error codes // //--------------------------------------- static const int32 ERR = (int32)90300; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // define the symbol that is represented by this node // Long symbol_id_d; // define the underlying statistical model for this node. // this could be a gaussian, or a laplacian, or any such statistical model. // if stat_model_d is not set then evaluations do not take place // int32 model_id_d; StatisticalModel* stat_model_d; // define the level this node exists at in the main graph // SearchLevel* level_d; // define the level this node exists at in the main graph // LexicalTree* lex_tree_d; // define a set of traces at this node in the search // DoubleLinkedList traces_d; // define a set of traces at this node in the search // DoubleLinkedList instances_d; // define the current time stamp for this node // int32 timestamp_d; // define the current score // float32 score_d; // define a static debug level // static Integral::DEBUG debug_level_d; // define a static memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG debug_level); // method: debug // bool8 debug(const unichar* message) const; // method: setDebug // static bool8 setDebug(Integral::DEBUG debug_level) { debug_level_d = debug_level; return true; } // method: destructor // ~SearchNode() { if (debug_level_d >= Integral::ALL) { fprintf(stdout, "Destructor of search_node: %p\n", this); fflush(stdout); } } // constructor(s) // SearchNode(); SearchNode(const SearchNode& copy_node); // assign methods // bool8 assign(const SearchNode& copy_node); // method: sofSize // int32 sofSize() const { return Error::handle(name(), L"sofSize", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false) { return Error::handle(name(), L"readData", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const { return Error::handle(name(), L"writeData", Error::NOT_IMPLEM, __FILE__, __LINE__); } // equality method // bool8 eq(const SearchNode& compare_node) const; // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // clear methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // method: setModelId // bool8 setModelId(const int32 arg) { return (model_id_d = arg); } // method: getModelId // int32 getModelId() const { return model_id_d; } // symbol id methods // bool8 setSymbolId(int32 symbol_id); // method: getSymbolId // int32 getSymbolId() const { int32 index = symbol_id_d; // dummy node will have negative index // if ( index <= DEF_DUMMY_SYMBOL_ID ){ index = DEF_DUMMY_SYMBOL_ID - index; } return index; } // method: isDummyNode // bool8 isDummyNode() const { // dummy node will have negative index // return ( symbol_id_d <= DEF_DUMMY_SYMBOL_ID ); } // symbol methods // bool8 setSymbol(const SearchSymbol& symbol); bool8 getSymbol(SearchSymbol& output_symbol) const; // method: setStatisticalModel // bool8 setStatisticalModel(StatisticalModel* model) { stat_model_d = model; return true; } // method: getStatisticalModel // StatisticalModel* getStatisticalModel() const { return stat_model_d; } // method: setScore // bool8 setScore(float32 score) { score_d = score; return true; } // method: getScore // float32 getScore() const { return score_d; } // method: setSearchLevel // bool8 setSearchLevel(SearchLevel* level) { level_d = level; return true; } // method: getSearchLevel // SearchLevel* getSearchLevel() const { return level_d; } // method: setLexicalTree // bool8 setLexicalTree(LexicalTree* lex_tree_a) { lex_tree_d = lex_tree_a; return true; } // method: getLexicalTree // LexicalTree* getLexicalTree() const { return lex_tree_d; } // trace list manipulation methods // bool8 addTrace(Trace* trace, int32 timestamp, Trace*& ptr); bool8 mergeTrace(Trace* trace, int32 timestamp, Trace*& ptr, int32 nsymbol_index, int32 nsymbol_order); bool8 removeTrace(Trace* trace); bool8 clearTraceList(); // instance list manipulation methods // bool8 addInstance(Instance* instance, int32 timestamp, Instance*& ptr); bool8 insertInstance(Instance* instance, int32 timestamp, Instance*& ptr); bool8 mergeInstance(Instance* instance, int32 timestamp, Instance*& ptr, int32 nsymbol_index, int32 nsymbol_order); bool8 removeInstance(Instance* instance); bool8 clearInstanceList(); // computational method // float32 evaluateData(VectorFloat& data, int32 timestamp); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // trace tracking methods // bool8 addWithViterbi(Trace* trace, Trace*& ptr); bool8 addWithBaumWelch(Trace* trace, Trace*& ptr); // instance tracking methods // bool8 addWithViterbi(Instance* instance, Instance*& ptr); bool8 insertWithViterbi(Instance* instance, Instance*& ptr); bool8 addWithBaumWelch(Instance* instance, Instance*& ptr); }; // include the train node class here circumvent the circular dependency // #ifndef ISIP_SEARCH_LEVEL #include #endif #ifndef ISIP_LEXICAL_TREE #include #endif // end of include file // #endif