diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-23 22:12:00 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-23 22:12:00 +0000 |
commit | f77386b66de684a6870b9c27e8ffc744258a92dd (patch) | |
tree | 8fa3b00a4554df3b1f9cbe944418ca94bc3eb07a /decoder | |
parent | 7fe231401fbb0f934f54c071e10fdeb4dc566d57 (diff) |
pretty
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@389 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rwxr-xr-x | decoder/ff_from_fsa.h | 18 | ||||
-rw-r--r-- | decoder/sparse_vector.h | 11 |
2 files changed, 13 insertions, 16 deletions
diff --git a/decoder/ff_from_fsa.h b/decoder/ff_from_fsa.h index 820f2433..03de25f8 100755 --- a/decoder/ff_from_fsa.h +++ b/decoder/ff_from_fsa.h @@ -77,21 +77,21 @@ public: WP al=(WP)a; WP ale=left_end(a); // scan(al,le) these - the same as below else. macro for now; pull into closure object later? - int nw=ale-al; - if (left_out+nw<left_full) { // nothing to score + int nw=ale-al; // this many new words + if (left_out+nw<left_full) { // nothing to score after adding wordcpy(left_out,al,nw); left_out+=nw; - } else if (left_out<left_full) { // something to score AND left context to fill + } else if (left_out<left_full) { // something to score AND newly full left context to fill int ntofill=left_full-left_out; + assert(ntofill==M-(left_out-left_begin)); wordcpy(left_out,al,ntofill); left_out=(W)left_full; // heuristic known now fsa.reset(h_start); fsa.scan(left_begin,left_full,estimated_features); // save heuristic (happens once only) + fsa.scan(al+ntofill,ale,features); al+=ntofill; // we used up the first ntofill words of al to end up in some known state via exactly M words total (M-ntofill were there beforehand). now we can scan the remaining al words of this child - goto scan; - } else { // more to score / state to update - scan: + } else { // more to score / state to update (left already full) fsa.scan(al,ale,features); } if (nw>M) // child had full state already (had a "gap"); if nw==M then we already reached the same state via left word heuristic scan above @@ -111,11 +111,11 @@ public: } } - if (left_out<left_full) { // finally: partial heuristic fo runfilled items + if (left_out<left_full) { // finally: partial heuristic foru nfilled items fsa.reset(h_start); - fsa.scan(left_begin,left_out,estimated_features); // save heuristic (happens once) + fsa.scan(left_begin,left_out,estimated_features); clear_fsa_state(out_state); // 0 bytes so we compare / hash correctly. don't know state yet - while(left_out<left_full) *left_out++=TD::none; // mark as partial left word seq + do { *left_out++=TD::none; } while(left_out<left_full); // none-terminate so left_end(out_state) will know how many words } else // or else store final right-state. heuristic was already assigned fstatecpy(out_state,fsa.cs); FSAFFDBG(" = " << describe_state(out_state)<<" "<<(*features)[ff.fid()]<<" h="<<(*estimated_features)[ff.fid()]<<'\n'); diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h index 285e84a7..f8310fc1 100644 --- a/decoder/sparse_vector.h +++ b/decoder/sparse_vector.h @@ -90,6 +90,10 @@ public: return found->second; } + T value(int index) const { + return (*this)[index]; + } + void set_value(int index, const T &value) { values_[index] = value; } @@ -101,13 +105,6 @@ public: return val; } - T value(int index) const { - typename MapType::const_iterator found = values_.find(index); - if (found != values_.end()) - return found->second; - else - return 0; - } void store(std::valarray<T>* target) const { (*target) *= 0; |