📄 hierarchicalsearch.h
字号:
// method: setInitialLevel // boolean setInitialLevel(long init_level) { initial_level_d = init_level; return true; } // method: getInitialLevel // long getInitialLevel() const { return (long)initial_level_d; } // search level manipulation // boolean setNumLevels(long num_levels); // method: getNumLevels // long getNumLevels() const { return search_levels_d.length(); } // method: getContextLevel // long getContextLevel() { return (long)context_level_d; } // method: setContextLevel // boolean setContextLevel(long arg) { return context_level_d.assign(arg); } // method: getContextList // Vector<String>& getContextList() { return context_list_d; } // method: setContextList // boolean setContextList(Vector<String>& arg) { return context_list_d.assign(arg); } // method: setFeatures // boolean setFeatures(Vector<VectorFloat>& features) { current_frame_d = DEF_START_FRAME; return true; } // method: getSearchLevel // SearchLevel& getSearchLevel(long level) { return search_levels_d(level); } // method: getSearchLevels // Vector<SearchLevel>& getSearchLevels() { return search_levels_d; } // method: getContextPool // ContextPool& getContextPool() { return context_pool_d; } // method: setContextPool // boolean setContextPool(ContextPool& arg) { return context_pool_d.assign(arg); } // method: getHistoryPool // HistoryPool& getHistoryPool() { return history_pool_d; } // method: setHistoryPool // boolean setHistoryPool(HistoryPool& arg) { return history_pool_d.assign(arg); } // search initialization methods // boolean initializeLinearDecoder(); boolean initializeLinearPartial(); boolean initializeGrammarDecoder(); boolean initializeGrammarPartial(); boolean initializeNetworkDecoder(); boolean initializeContextGeneration(); // decoding methods // boolean linearDecoder(FrontEnd& fe, long num_frames = DEF_NUM_FRAMES); boolean linearDecoder(Vector<VectorFloat>& fe, long num_frames = DEF_NUM_FRAMES); boolean grammarDecoder(FrontEnd& fe, long num_frames = DEF_NUM_FRAMES); boolean grammarDecoder(Vector<VectorFloat>& fe, long num_frames = DEF_NUM_FRAMES); boolean networkDecoder(FrontEnd& fe, long num_frames = DEF_NUM_FRAMES); boolean networkDecoder(Vector<VectorFloat>& fe, long num_frames = DEF_NUM_FRAMES); // hypothesis methods // boolean getHypotheses(String& output_hyp, long level, double& total_score, long& num_frames, DoubleLinkedList<Trace>& trace_path); boolean getHypotheses(String& output_hyp, long level, double& total_score, long& num_frames, DoubleLinkedList<Instance>& trace_path); boolean convertLexInstances( DoubleLinkedList<Instance>& instance_path); boolean printInstances( DoubleLinkedList<Instance>& instance_path); boolean getLexHypotheses(String& output_hyp, long level, float& total_score, long& num_frames, DoubleLinkedList<Instance>& trace_path); boolean forcedAlignment(String& alignment, Long level, DoubleLinkedList<Trace>& trace_path, boolean cumulative = false); // trace manipulation methods // boolean connectValidHypothesis(); BiGraphVertex<TrainNode>* insertTrace(Trace* arg); BiGraphVertex<TrainNode>* insertInstance(Instance* arg); // trellis state occupancy computation routines // BiGraph<TrainNode>* computeForwardBackward(Vector<VectorFloat>& data, float beta_threshold); //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // search initialization methods // boolean clearTraceStorage(); boolean clearSearchNodesTraceLists(); boolean clearValidHypsTrace(); boolean clearInstanceStorage(); boolean clearSearchNodesInstanceLists(); boolean clearValidHypsInstance(); boolean clearValidHypsLexInstance(); // search traversal methods // boolean traverseTraceLevels(); boolean pathsRemainTrace(); boolean traverseInstanceLevels(); boolean pathsRemainInstance(); // trace propagation methods // boolean propagateTraces(); boolean propagateTracesDown(long level_num); boolean propagateTracesUp(long level_num); boolean evaluateTraceModels(); // instance propagation methods // boolean propagateInstances(); boolean propagateInstancesDown(long level_num); boolean propagateInstancesUp(long level_num); boolean evaluateInstanceModels(); boolean evaluateLexInstanceModels(); // trace bookkeeping methods // long getActiveTraces(long search_level = ALL_LEVELS); // instance bookkeeping methods // long getActiveInstances(long search_level = ALL_LEVELS); // debugging methods // boolean printNewPath(Trace* new_trace, Trace* old_trace); boolean printDeletedPath(Trace* new_trace, Trace* old_trace); boolean printNewPath(Instance* new_instance, Instance* old_instance); boolean printDeletedPath(Instance* new_instance, Instance* old_instance); // trellis insertion methods // boolean insertNewPath(Trace* parent, Trace* child, float weight); boolean insertOldPath(Trace* parent, Trace* child, float weight); boolean insertNewPath(Instance* parent, Instance* child, float weight); boolean insertOldPath(Instance* parent, Instance* child, float weight); // method: getPosteriorScore (not implemented yet) // float getPosteriorScore(Trace* curr_trace) { return 0.0; } // method to compute the n-symbol probability // float getPosteriorScore(Context* context, long level); // pruning method // boolean beamPruneTrace(long level_num); boolean beamPruneInstance(long level_num); boolean instancePruneTrace(long level_num); boolean instancePruneInstance(long level_num); boolean beamPruneLexInstance(long level_num); boolean instancePruneLexInstance(long level_num); // initialization routine // boolean initializeForwardBackward(); // backward probability computation routines // boolean computeBackward(Vector<VectorFloat>& data, float beta_threshold); boolean computeBeta(Vector<VectorFloat>& data, BiGraphVertex<TrainNode>* vertex, float** model_cache); // forward probability computation routines // boolean computeForward(Vector<VectorFloat>& data); boolean computeAlpha(Vector<VectorFloat>& data, BiGraphVertex<TrainNode>* vertex); // cross-word context related methods // boolean generateRightContexts(DoubleLinkedList<Context>& context_list, DoubleLinkedList<Float>& score_list, Context* initial_context, long depth, long level); boolean initializeRightContexts(Instance* curr_instance, Context& init_context, long level_num, float curr_weight, long depth); boolean extendRightContexts(Instance* curr_instance, long level_num, Context* prev_symbol = (Context*)NULL); boolean printHistory(const History* history); boolean isTerminal(Instance* curr_instance, long level_num); boolean propagateUp(long curr_level, long level, long curr_depth, long depth, DoubleLinkedList<Instance>& inst_list, DoubleLinkedList<History>& curr_hist, DoubleLinkedList<History>& prev_hist, DoubleLinkedList<Float>& score_list); boolean propagateDown(Context* symbol, Context* symbol1, GraphVertex<SearchNode>* curr_vertex, long curr_level, long level, long curr_depth, long depth, DoubleLinkedList<Instance>& inst_list, DoubleLinkedList<History>& curr_hist, DoubleLinkedList<History>& prev_hist, DoubleLinkedList<Float>& score_list); boolean ascend(Instance* instance); boolean descend(Instance* instance); boolean lookAhead(long level, long depth, DoubleLinkedList<Instance>& inst_list, DoubleLinkedList<Float>& score_list); boolean lookAheadHelper(GraphVertex<SearchNode>* curr_vertex, long curr_level, long level, long curr_depth, long depth, DoubleLinkedList<Instance>& inst_list, DoubleLinkedList<History>& curr_hist, DoubleLinkedList<History>& prev_hist, DoubleLinkedList<Float>& score_list); // context related methods // boolean generateRightLexContexts(DoubleLinkedList<Context>& context_list, const Context& initial_context, long depth, long level); // start search engine from linear structure // boolean linearStart(); // start search engine from lexical tree structure // boolean lexicalTreeStart(); // initialize the lexical tree // boolean initializeLexicalTree(); // lexical tree related methods // boolean printInstance(Instance* new_instance, long level_num = -1, boolean recursive = false); boolean changeHistory(Instance*& curr_instance, boolean ascend, long level_num = 0, GraphVertex<SearchNode>* start_vert = (GraphVertex<SearchNode>*)NULL); boolean addHypothesisPath(Trace*& new_instance, Trace*& old_instance, long level_num, float weight); boolean addHypothesisPath(Instance*& new_instance, Instance*& old_instance, long level_num, float weight); boolean addInstance(long level_num, Instance*& curr_instance, Instance*& next_instance, boolean pruning); boolean ascendInstance(long level_num, Instance*& curr_instance); boolean descendInstance(long level_num, Instance*& curr_instance); boolean traverseLexInstanceLevels(); boolean propagateLexInstances(); boolean propagateLexInstancesUp(long level_num); boolean propagateLexInstancesDown(long level_num); boolean networkLexStart(); boolean expandLexicalTree(long level_num); // convert hypotheses // boolean addToPath( Instance*& curr_inst, Instance*& prev_inst, Vector< DoubleLinkedList<Instance> >& inst_levels, Vector< DoubleLinkedList<Instance> >& prev_levels, long level_num, long& frame_ind, DoubleLinkedList<Instance>& instance_path); // n-symbol probability related methods // boolean shiftNSymbol(Trace*& trace, long level, GraphVertex<SearchNode>* vertex); boolean shiftNSymbol(Instance*& instance, long level, GraphVertex<SearchNode>* vertex); boolean initializeNsymbolInstance(Instance*& instance); boolean initializeNsymbolTrace(Trace*& trace); boolean applyNSymbolScore(Instance*& curr_instance, long level_num); boolean addInstanceScore(Instance*& curr_instance, float score, long level_num, boolean weight_score); };// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -