PR #3279 - Fixed spaces
This commit is contained in:
parent
f07c10452b
commit
15ce05aa01
@ -96,7 +96,7 @@ DecoderState::next(const double *probs,
|
|||||||
if (full_beam && log_prob_c + prefix->score < min_cutoff) {
|
if (full_beam && log_prob_c + prefix->score < min_cutoff) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(prefix->is_empty() || prefix->timesteps!=nullptr);
|
assert(prefix->is_empty() || prefix->timesteps != nullptr);
|
||||||
|
|
||||||
// blank
|
// blank
|
||||||
if (c == blank_id_) {
|
if (c == blank_id_) {
|
||||||
@ -242,7 +242,7 @@ DecoderState::decode(size_t num_results) const
|
|||||||
output.timesteps = get_history(prefix->timesteps);
|
output.timesteps = get_history(prefix->timesteps);
|
||||||
output.confidence = scores[prefix];
|
output.confidence = scores[prefix];
|
||||||
outputs.push_back(output);
|
outputs.push_back(output);
|
||||||
if(outputs.size()>=num_returned) break;
|
if (outputs.size() >= num_returned) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
|
@ -179,11 +179,11 @@ void PathTrie::iterate_to_vec(std::vector<PathTrie*>& output) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timesteps == nullptr){
|
if (timesteps == nullptr) {
|
||||||
timesteps = add_child(previous_timesteps, new_timestep);
|
timesteps = add_child(previous_timesteps, new_timestep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
previous_timesteps=nullptr;
|
previous_timesteps = nullptr;
|
||||||
|
|
||||||
output.push_back(this);
|
output.push_back(this);
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
* It is used to store the timesteps data for the PathTrie below
|
* It is used to store the timesteps data for the PathTrie below
|
||||||
*/
|
*/
|
||||||
template<class DataT>
|
template<class DataT>
|
||||||
struct TreeNode{
|
struct TreeNode {
|
||||||
TreeNode<DataT>* parent;
|
TreeNode<DataT>* parent;
|
||||||
std::vector<std::unique_ptr< TreeNode<DataT>, godefv::memory::object_pool_deleter_t<TreeNode<DataT>> >> children;
|
std::vector<std::unique_ptr< TreeNode<DataT>, godefv::memory::object_pool_deleter_t<TreeNode<DataT>> >> children;
|
||||||
|
|
||||||
DataT data;
|
DataT data;
|
||||||
@ -30,7 +30,7 @@ TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* node, ChildDataT&& data_);
|
|||||||
template<class DataT>
|
template<class DataT>
|
||||||
std::vector<DataT> get_history(TreeNode<DataT>*);
|
std::vector<DataT> get_history(TreeNode<DataT>*);
|
||||||
|
|
||||||
using TimestepTreeNode=TreeNode<unsigned int>;
|
using TimestepTreeNode = TreeNode<unsigned int>;
|
||||||
|
|
||||||
/* Trie tree for prefix storing and manipulating, with a dictionary in
|
/* Trie tree for prefix storing and manipulating, with a dictionary in
|
||||||
* finite-state transducer for spelling correction.
|
* finite-state transducer for spelling correction.
|
||||||
@ -85,10 +85,10 @@ public:
|
|||||||
float score;
|
float score;
|
||||||
float approx_ctc;
|
float approx_ctc;
|
||||||
unsigned int character;
|
unsigned int character;
|
||||||
TimestepTreeNode* timesteps=nullptr;
|
TimestepTreeNode* timesteps = nullptr;
|
||||||
|
|
||||||
// timestep temporary storage for each decoding step.
|
// timestep temporary storage for each decoding step.
|
||||||
TimestepTreeNode* previous_timesteps=nullptr;
|
TimestepTreeNode* previous_timesteps = nullptr;
|
||||||
unsigned int new_timestep;
|
unsigned int new_timestep;
|
||||||
|
|
||||||
PathTrie* parent;
|
PathTrie* parent;
|
||||||
@ -108,21 +108,21 @@ private:
|
|||||||
|
|
||||||
// TreeNode implementation
|
// TreeNode implementation
|
||||||
template<class NodeDataT, class ChildDataT>
|
template<class NodeDataT, class ChildDataT>
|
||||||
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* node, ChildDataT&& data_){
|
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* node, ChildDataT&& data_) {
|
||||||
static godefv::memory::object_pool_t<TreeNode<NodeDataT>> tree_node_pool;
|
static godefv::memory::object_pool_t<TreeNode<NodeDataT>> tree_node_pool;
|
||||||
node->children.push_back(tree_node_pool.make_unique(node, std::forward<ChildDataT>(data_)));
|
node->children.push_back(tree_node_pool.make_unique(node, std::forward<ChildDataT>(data_)));
|
||||||
return node->children.back().get();
|
return node->children.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class DataT>
|
template<class DataT>
|
||||||
void get_history_helper(TreeNode<DataT>* tree_node, std::vector<DataT>* output){
|
void get_history_helper(TreeNode<DataT>* tree_node, std::vector<DataT>* output) {
|
||||||
if(tree_node==nullptr) return;
|
if (tree_node == nullptr) return;
|
||||||
assert(tree_node->parent != tree_node);
|
assert(tree_node->parent != tree_node);
|
||||||
get_history_helper(tree_node->parent, output);
|
get_history_helper(tree_node->parent, output);
|
||||||
output->push_back(tree_node->data);
|
output->push_back(tree_node->data);
|
||||||
}
|
}
|
||||||
template<class DataT>
|
template<class DataT>
|
||||||
std::vector<DataT> get_history(TreeNode<DataT>* tree_node){
|
std::vector<DataT> get_history(TreeNode<DataT>* tree_node) {
|
||||||
std::vector<DataT> output;
|
std::vector<DataT> output;
|
||||||
get_history_helper(tree_node, &output);
|
get_history_helper(tree_node, &output);
|
||||||
return output;
|
return output;
|
||||||
|
Loading…
Reference in New Issue
Block a user