summaryrefslogtreecommitdiff
path: root/decoder/ff_sample_fsa.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 22:12:06 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-23 22:12:06 +0000
commit3e1f5d7ad9aff3e572e25e0afc2ae10b438e8962 (patch)
tree77c8c7b55de7d3e458cd6fa079f4ee12f35480e0 /decoder/ff_sample_fsa.h
parentb9574d2c459b60037bf1e97e64e0c4aed524a71c (diff)
pretty
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@390 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_sample_fsa.h')
-rwxr-xr-xdecoder/ff_sample_fsa.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/decoder/ff_sample_fsa.h b/decoder/ff_sample_fsa.h
index 8befc0bb..d8aa7830 100755
--- a/decoder/ff_sample_fsa.h
+++ b/decoder/ff_sample_fsa.h
@@ -31,11 +31,12 @@ typedef FeatureFunctionFromFsa<WordPenaltyFsa> WordPenaltyFromFsa;
//
struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> {
+ typedef FsaFeatureFunctionBase<LongerThanPrev> Base;
static std::string usage(bool param,bool verbose) {
return FeatureFunction::usage_helper(
"LongerThanPrev",
"",
- "stupid example stateful (bigram) feature: -1 per target word that's longer than the previous word (always fires for first word of sentence)",
+ "stupid example stateful (bigram) feature: -1 per target word that's longer than the previous word (<s> sentence begin considered 3 chars long, </s> is sentence end.)",
param,verbose);
}
@@ -49,16 +50,21 @@ struct LongerThanPrev : public FsaFeatureFunctionBase<LongerThanPrev> {
return std::strlen(TD::Convert(w));
}
int markov_order() const { return 1; }
- LongerThanPrev(std::string const& param) {
+ LongerThanPrev(std::string const& param) : Base(sizeof(int),singleton_sentence(TD::se)) {
Init();
- set_state_bytes(sizeof(int));
-// start.resize(state_bytes()); // this is done by set_state_bytes already.
-// h_start.resize(state_bytes());
-// int ss=-1;
-// wordcpy((WordID*)start.begin(),&ss,&ss+1);
- //to_state(start.begin(),&ss,1);
- wordlen(start.begin())=-1;
+ 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());
+ int ss=3;
+ to_state(start.begin(),&ss,1);
+ ss=4;
+ to_state(h_start.begin(),&ss,1);
+ }
+
+ wordlen(start.begin())=3;
wordlen(h_start.begin())=4; // estimate: anything >4 chars is usually longer than previous
+
}
static const float val_per_target_word=-1;
@@ -79,7 +85,7 @@ struct ShorterThanPrev : FsaTypedBase<int,ShorterThanPrev> {
return FeatureFunction::usage_helper(
"ShorterThanPrev",
"",
- "stupid example stateful (bigram) feature: -1 per target word that's shorter than the previous word (always fires for end of sentence)",
+ "stupid example stateful (bigram) feature: -1 per target word that's shorter than the previous word (end of sentence considered '</s>')",
param,verbose);
}
@@ -87,7 +93,7 @@ struct ShorterThanPrev : FsaTypedBase<int,ShorterThanPrev> {
return std::strlen(TD::Convert(w));
}
ShorterThanPrev(std::string const& param)
- : Base(-1,4,Sentence(1,TD::Convert("")))
+ : Base(3,4,singleton_sentence(TD::se))
// start, h_start, end_phrase
// estimate: anything <4 chars is usually shorter than previous
{