From 8a841e06196b3c1149d7548968da36b09183f19b Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 23 Jul 2010 03:15:20 +0000 Subject: 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 --- decoder/ff_from_fsa.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'decoder') 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. score(full left unscored phrase) AccumFeatures(ff,smeta,begin(ends),end(ends),final_features,rst); // e.g. [ctx for last M words] score("") @@ -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)); -- cgit v1.2.3