diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-31 01:56:56 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-31 01:56:56 +0000 |
commit | 6165a7852d01439d20ed5ee1814798863a3d5bf7 (patch) | |
tree | 79c893eea7572c70e3149db79562e61b25ffa5af /decoder | |
parent | e4175086a36fbaf752b8a2dae089b9081ac5880f (diff) |
l2r bugfixes
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@635 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rwxr-xr-x | decoder/apply_fsa_models.cc | 7 | ||||
-rw-r--r-- | decoder/hg.h | 3 | ||||
-rw-r--r-- | decoder/inside_outside.h | 2 | ||||
-rw-r--r-- | decoder/viterbi.h | 2 |
4 files changed, 10 insertions, 4 deletions
diff --git a/decoder/apply_fsa_models.cc b/decoder/apply_fsa_models.cc index 4a928206..83083fc5 100755 --- a/decoder/apply_fsa_models.cc +++ b/decoder/apply_fsa_models.cc @@ -495,9 +495,8 @@ typedef Item *ItemP; /* we use a single type of item so it can live in a single best-first queue. we hold them by pointer so they can have mutable state, e.g. priority/location, but also lists of predictions and kbest completions (i.e. completions[L,r] = L -> * (r,s), by 1best for each possible s. we may discover more s later. we could use different subtypes since we hold by pointer, but for now everything will be packed as variants of Item */ struct Item : ItemPrio,ItemKey { - explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0) { } - explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0) { } - unsigned location; + explicit Item(NodeP dot,int next=0) : ItemKey(dot),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { } + explicit Item(NodeP dot,FFState const& state,int next=0) : ItemKey(dot,state),next(next),from(0),location(D_ARY_HEAP_NULL_INDEX) { } typedef std::queue<ItemP> Predicted; Predicted predicted; // this is empty, unless this is a predicted L -> .asdf item, or a to-complete L -> asdf . int next; // index of dot->adj to complete (if dest==0), or predict (if NT), or scan (if word). note: we could store pointer inside adj since it and trie are @ fixed addrs. less pointer arith, more space. @@ -517,6 +516,7 @@ struct Item : ItemPrio,ItemKey { o<< ']'; } PRINT_SELF(Item) + unsigned location; }; struct GetItemKey { @@ -645,6 +645,7 @@ void ApplyFsa<F>::ApplyEarley() Chart<F> chart(cfg,smeta,fsa); // don't need to uniq - option to do that already exists in cfg_options //TODO: + *oh=hgcfg.ih; } diff --git a/decoder/hg.h b/decoder/hg.h index 76b2b8f0..a78746b0 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -298,6 +298,9 @@ public: std::swap(is_linear_chain_, other.is_linear_chain_); other.edges_.swap(edges_); } + friend inline void swap(Hypergraph &a,Hypergraph &b) { + a.swap(b); + } void ResizeNodes(int size) { nodes_.resize(size); diff --git a/decoder/inside_outside.h b/decoder/inside_outside.h index 73d4ec6a..e6289176 100644 --- a/decoder/inside_outside.h +++ b/decoder/inside_outside.h @@ -55,7 +55,7 @@ WeightType Inside(const Hypergraph& hg, *cur_node_inside_score += score; } } - return inside_score.back(); + return inside_score.empty() ? WeightType(0) : inside_score.back(); } template<class WeightType, class WeightFunction> diff --git a/decoder/viterbi.h b/decoder/viterbi.h index e78cd157..ac0b9a11 100644 --- a/decoder/viterbi.h +++ b/decoder/viterbi.h @@ -55,6 +55,8 @@ typename WeightFunction::Weight Viterbi(const Hypergraph& hg, antsb[k] = &vit_result[edgeb.tail_nodes_[k]]; traverse(edgeb, antsb, cur_node_best_result); } + if (vit_result.empty()) + return WeightType(0); std::swap(*result, vit_result.back()); return vit_weight.back(); } |