📄 stacksearch.h
字号:
// file: $isip/class/search/StackSearch/StackSearch.h// version: $Id: StackSearch.h,v 1.6 2002/12/06 17:04:03 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_STACK_SEARCH#define ISIP_STACK_SEARCH// isip include files://#ifndef ISIP_HYPOTHESIS#include <Hypothesis.h>#endif#ifndef ISIP_HASH_KEY#include <HashKey.h>#endif#ifndef ISIP_MATRIX_FLOAT#include <MatrixFloat.h>#endif#ifndef ISIP_FRONTEND#include <FrontEnd.h>#endif// StackSearch: A hierarchical, asynchronous, stack search engine.//// StackSearch can decode same hierarchical structure of graphs.// Decoding algorithm follows the multistack approach described in://// Renals S., Hochberg. M.: Decoder Technology for Connectionist// Large Vocabulary Speech Recognition// // class StackSearch { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; //---------------------------------------- // // other important constants // //---------------------------------------- // define the start frame index // static const long START_FRAME = -1; // define how many frames to decode // static const long ALL_FRAMES = -1; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // static const long DEF_NUM_LEVELS = 3; static const long MAX_NUM_FRAMES = 1000; static const long DEF_N_BEST = 1; // default arguments to methods // static const long ALL_LEVELS = -1; //--------------------------------------- // // error codes // //--------------------------------------- static const long ERR = (long)90800; static const long ERR_LEVELS_NOT_LOADED = (long)90801; //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: // type definition // typedef GraphVertex<SearchNode> GVSnode; // feature vectors // Vector<VectorFloat> features_d; // total number of frames to decode // Long num_frames_d; // number of best word hypotheses to find // Long n_best_d; // current frame in the search // Long current_frame_d; // search levels, sub-graphs are maintained at each SearchLevel // Vector<SearchLevel> search_levels_d; // vector that contains the location (index) of the nsymbol mapping // Vector<Long> nsymbol_mapping_d; // vector that contains the location (index) of the context mapping // Vector<Long> context_mapping_d; // maximal trace scores at each frame for all levels // used for beam pruning // MatrixFloat max_frame_scores_d; // maximal trace scores for stacks // VectorFloat max_stack_scores_d; // statistical model scores // MatrixFloat stat_model_scores_d; // lists to keep track of traces during the search // Vector<DoubleLinkedList<Trace> > trace_lists_d; DoubleLinkedList<Trace> valid_hyps_d; // vector of hypothesis stacks // each stack contains word level hypothesess of one frame // Vector< HashTable<HashKey<GraphVertex<SearchNode> >, Stack<Hypothesis> > > stacks_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; } static boolean diagnose(Integral::DEBUG debug_level); // debug methods: // the setDebug method for this class is static because the debug_level is // shared across all objects of this class // boolean debug(const unichar* message) const; // method: setDebug // static boolean setDebug(Integral::DEBUG debug_level) { debug_level_d = debug_level; return true; } // destructor/constructor(s) // ~StackSearch(); StackSearch(); StackSearch(const StackSearch& copy_search); // method: assign // boolean assign(const StackSearch& copy_search) { return Error::handle(name(), L"assign", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: sofSize // long sofSize() const { return Error::handle(name(), L"sofSize", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: read // boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME) { return Error::handle(name(), L"read", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: write // boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const { return Error::handle(name(), L"write", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: readData // boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false) { return Error::handle(name(), L"readData", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: writeData // boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const { return Error::handle(name(), L"writeData", Error::NOT_IMPLEM, __FILE__, __LINE__); } // method: eq // boolean eq(const StackSearch& compare_search) const { return search_levels_d.eq(compare_search.search_levels_d); } // 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 boolean setGrowSize(long grow_size) { return mgr_d.setGrow(grow_size); } // clear method // boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- // search level manipulation // boolean setNumLevels(long num_levels); // method: getNumLevels // long getNumLevels() const { return search_levels_d.length(); } // method: setFrame // boolean setFrame(long frame) { return (current_frame_d = frame); } // method: getFrame // long getFrame() const { return current_frame_d; } // method: getSearchLevel // SearchLevel& getSearchLevel(long level) { return search_levels_d(level); } // method: getSearchLevels // Vector<SearchLevel>& getSearchLevels() { return search_levels_d; } // search initialization methods // boolean initSizes(long total_num_frames); boolean initializeLinearDecoder(); // decoding methods // boolean decode(FrontEnd& fe, long num_frames = ALL_FRAMES); boolean decode(Vector<VectorFloat>& features, long num_frames = ALL_FRAMES); // hypothesis methods // boolean getHypotheses(String& output_hyp, long level_a, double& total_score, long& num_frames, DoubleLinkedList<Trace>& trace_path); //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // search initialization methods // boolean clearTraceStorage(); boolean clearSearchNodesTraceLists(); boolean clearValidHypsTrace(); // search traversal methods // boolean traverseTraceLevels(); boolean pathsRemainTrace(); // trace propagation methods // boolean propagateTraces(DoubleLinkedList<Trace>* top_list = NULL); boolean propagateTracesDown(long level_num_a); boolean propagateTracesUp(long level_num_a, DoubleLinkedList<Trace>* top_list = NULL); boolean evaluateTraceModels(); // trace bookkeeping methods // long getActiveTraces(long search_level = ALL_LEVELS); // debugging methods // boolean printNewPath(Trace* new_trace, Trace* old_trace); boolean printDeletedPath(Trace* new_trace, Trace* old_trace); // pruning method // boolean beamPruneTrace(long level_num); // context related methods // boolean generateRightContexts(DoubleLinkedList<Context>& context_list, const Context& initial_context, long depth); boolean generateInitialTraces(); // method extending hypothesis by one word // boolean extend(DoubleLinkedList<Trace>& hlist, long start_frame); boolean getTraces(DoubleLinkedList<Trace>& trace_list, long level_a); boolean setTopLevelTraces(DoubleLinkedList<Trace>& top_trace_list); boolean decode();};// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -