summaryrefslogtreecommitdiff
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
commitbcf7ad8a05799172ccd5d6ce73ddcd2f4c4a174e (patch)
treea97ac5f5be280711af522c907af345d37f612761
parentc70e58a62d9f2fed4df0665202c2eb44334dfd8c (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
-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));