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