summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 03:15:20 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 03:15:20 +0000
commit8a841e06196b3c1149d7548968da36b09183f19b (patch)
treea8b6307785a0ce38a4da2f68bd6a5d98d45c641c /decoder
parent8c6536c56c728213b9e1190f0c9f76f7b4948140 (diff)
fsa: final features opt. for 0 state, correct left_end when # words = 0
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@374 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder')
-rwxr-xr-xdecoder/ff_from_fsa.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/decoder/ff_from_fsa.h b/decoder/ff_from_fsa.h
index 3bd3f070..cb7255d8 100755
--- a/decoder/ff_from_fsa.h
+++ b/decoder/ff_from_fsa.h
@@ -111,10 +111,14 @@ public:
const void* residual_state,
FeatureVector* final_features) const
{
+ Sentence const& ends=ff.end_phrase();
+ SP ss=ff.start_state();
+ if (!ssz) {
+ AccumFeatures(ff,smeta,begin(ends),end(ends),final_features,ss);
+ return;
+ }
WP l=(WP)residual_state,lend=left_end(residual_state);
SP rst=fsa_state(residual_state);
- SP ss=ff.start_state();
- Sentence const& ends=ff.end_phrase();
if (lend==rst) { // implying we have an fsa state
AccumFeatures(ff,smeta,l,lend,final_features,ss); // e.g. <s> score(full left unscored phrase)
AccumFeatures(ff,smeta,begin(ends),end(ends),final_features,rst); // e.g. [ctx for last M words] score("</s>")
@@ -154,10 +158,10 @@ private:
*/
static inline WordID const* left_end(WordID const* left, WordID const* e) {
- while (e>left)
- if (*--e!=TD::none) break;
+ for (;e>left;--e)
+ if (e[-1]!=TD::none) break;
//post: [left,e] are the seen left words
- return e+1;
+ return e;
}
inline WP left_end(SP ant) const {
return left_end((WP)ant,(WP)fsa_state(ant));