diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-26 01:07:36 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-07-26 01:07:36 +0000 |
commit | 5dc4b5c2d796b339dd6b9f7616c5765ee28728f0 (patch) | |
tree | c3624b236eb7e88314fc439552af501e697214d5 /decoder/ff_sample_fsa.h | |
parent | 17623986ba1c9c9a3f91da4f215f25b9d9c0ea96 (diff) |
stateful ff_from_fsa works - fixed bug that never moved right state from rightmost variable up to result
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@413 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_sample_fsa.h')
-rwxr-xr-x | decoder/ff_sample_fsa.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/decoder/ff_sample_fsa.h b/decoder/ff_sample_fsa.h index 2aeaa6de..24f12560 100755 --- a/decoder/ff_sample_fsa.h +++ b/decoder/ff_sample_fsa.h @@ -28,7 +28,7 @@ struct WordPenaltyFsa : public FsaFeatureFunctionBase<WordPenaltyFsa> { typedef FeatureFunctionFromFsa<WordPenaltyFsa> WordPenaltyFromFsa; -// appears to be buggy right now: give it a bonus weight (-) and it overstates how many +// appears to be buggy right now: give it a bonus weight (+) struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> { typedef FsaFeatureFunctionBase<LongerThanPrev> Base; static std::string usage(bool param,bool verbose) { @@ -45,6 +45,15 @@ struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> { static inline int state(void const* st) { return *(int const*)st; } +/* int describe_state(void const* st) const { + return state(st); + } +*/ + // only need 1 of the 2 + void print_state(std::ostream &o,void const* st) const { + o<<state(st); + } + static inline int wordlen(WordID w) { return std::strlen(TD::Convert(w)); } @@ -53,14 +62,15 @@ struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> { Init(); if (0) { // all this is done in constructor already set_state_bytes(sizeof(int)); - start.resize(state_bytes()); // this is done by set_state_bytes already. - h_start.resize(state_bytes()); + //start.resize(state_bytes());h_start.resize(state_bytes()); // this is done by set_state_bytes already. int ss=3; to_state(start.begin(),&ss,1); ss=4; to_state(h_start.begin(),&ss,1); } - + assert(state_bytes()==sizeof(int)); + assert(start.size()==sizeof(int)); + assert(h_start.size()==sizeof(int)); state(start.begin())=999999; state(h_start.begin())=4; // estimate: anything >4 chars is usually longer than previous @@ -75,7 +85,7 @@ struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> { }; // similar example feature; base type exposes stateful type, defines markov_order 1, state size = sizeof(State) -// also buggy right now: give it a bonus weight (-) and it overstates how many +// also buggy right now: give it a bonus weight struct ShorterThanPrev : FsaTypedBase<int,ShorterThanPrev> { typedef FsaTypedBase<int,ShorterThanPrev> Base; static std::string usage(bool param,bool verbose) { |