diff --git a/native_client/ctcdecode/ctc_beam_search_decoder.cpp b/native_client/ctcdecode/ctc_beam_search_decoder.cpp index 874dc7c1..3d412155 100644 --- a/native_client/ctcdecode/ctc_beam_search_decoder.cpp +++ b/native_client/ctcdecode/ctc_beam_search_decoder.cpp @@ -37,7 +37,7 @@ DecoderState::init(const Alphabet& alphabet, prefix_root_.reset(root); prefix_root_->timesteps = ×tep_tree_root_; prefixes_.push_back(root); - + if (ext_scorer && (bool)(ext_scorer_->dictionary)) { // no need for std::make_shared<>() since Copy() does 'new' behind the doors auto dict_ptr = std::shared_ptr(ext_scorer->dictionary->Copy(true)); diff --git a/native_client/ctcdecode/path_trie.h b/native_client/ctcdecode/path_trie.h index d4d1e7cc..cab1b4ab 100644 --- a/native_client/ctcdecode/path_trie.h +++ b/native_client/ctcdecode/path_trie.h @@ -24,11 +24,17 @@ struct TreeNode { TreeNode(TreeNode* parent_, DataT const& data_): parent{parent_}, data{data_} {} }; +/* Creates a new TreeNode with given data as a child to the given node. + * Returns a pointer to the created node. This pointer remains valid as long as the child is not destroyed. + */ template -TreeNode* add_child(TreeNode* node, ChildDataT&& data_); +TreeNode* add_child(TreeNode* tree_node, ChildDataT&& data); +/* Returns the sequence of tree node's data from the given root (exclusive) to the given tree_node (inclusive). + * By default (if no root is provided), the full sequence from the root of the tree is returned. + */ template -std::vector get_history(TreeNode const*, TreeNode const* = nullptr); +std::vector get_history(TreeNode const* tree_node, TreeNode const* root = nullptr); using TimestepTreeNode = TreeNode; @@ -108,10 +114,10 @@ private: // TreeNode implementation template -TreeNode* add_child(TreeNode* node, ChildDataT&& data_) { +TreeNode* add_child(TreeNode* tree_node, ChildDataT&& data) { static thread_local godefv::memory::object_pool_t> tree_node_pool; - node->children.push_back(tree_node_pool.make_unique(node, std::forward(data_))); - return node->children.back().get(); + tree_node->children.push_back(tree_node_pool.make_unique(tree_node, std::forward(data))); + return tree_node->children.back().get(); } template