From 2cb224de7db49b761ac06b031090fe7f846744fe Mon Sep 17 00:00:00 2001 From: graehl Date: Sat, 24 Jul 2010 21:18:01 +0000 Subject: FSA: simpler Scan1 ScanT1 methods, otherewise also expose edge to full Scan git-svn-id: https://ws10smt.googlecode.com/svn/trunk@399 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/ff_sample_fsa.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'decoder/ff_sample_fsa.h') diff --git a/decoder/ff_sample_fsa.h b/decoder/ff_sample_fsa.h index 6e42b83b..74d9e7b5 100755 --- a/decoder/ff_sample_fsa.h +++ b/decoder/ff_sample_fsa.h @@ -19,10 +19,9 @@ struct WordPenaltyFsa : public FsaFeatureFunctionBase { start.clear(); h_start.clear(); } - static const float val_per_target_word=-1; // move from state to next_state after seeing word x, while emitting features->add_value(fid,val) possibly with duplicates. state and next_state may be same memory. - void Scan(SentenceMetadata const& smeta,WordID w,void const* state,void *next_state,FeatureVector *features) const { - features->add_value(fid_,val_per_target_word); + Featval Scan1(WordID w,void const* state,void *next_state) const { + return -1; } }; @@ -67,13 +66,11 @@ struct LongerThanPrev : public FsaFeatureFunctionBase { } - static const float val_per_target_word=-1; - void Scan(SentenceMetadata const& smeta,WordID w,void const* from,void *next_state,FeatureVector *features) const { + Featval Scan1(WordID w,void const* from,void *next_state) const { int prevlen=state(from); int len=wordlen(w); - if (len>prevlen) - features->add_value(fid_,val_per_target_word); state(next_state)=len; + return len>prevlen ? -1 : 0; } }; @@ -100,19 +97,18 @@ struct ShorterThanPrev : FsaTypedBase { Init(); } - static const float val_per_target_word=-1; + +/* Featval ScanT1(WordID w,int prevlen,int &len) const; + // alternative to below: + */ + // evil anti-google int & len out-param: - void ScanTyped(SentenceMetadata const& smeta,WordID w,int prevlen,int &len,FeatureVector *features) const { + void ScanT(SentenceMetadata const& /* smeta */,const Hypergraph::Edge& /* edge */,WordID w,int prevlen,int &len,FeatureVector *features) const { len=wordlen(w); if (lenadd_value(fid_,val_per_target_word); + features->add_value(fid_,-1); } - // already provided by FsaTypedScan -/* void Scan(SentenceMetadata const& smeta,WordID w,void const* st,void *next_state,FeatureVector *features) const { - ScanTyped(smeta,w,state(st),state(next_state),features); - } */ - }; -- cgit v1.2.3