diff options
author | jon.h.clark <jon.h.clark@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-11-12 20:28:09 +0000 |
---|---|---|
committer | jon.h.clark <jon.h.clark@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-11-12 20:28:09 +0000 |
commit | 5574acc916b1938fca3bf9d41fae6ca170f73b34 (patch) | |
tree | 89d20c9ee0137dce960d27347f312ce6d77bdcbb /decoder/ff_wordset.cc | |
parent | 29c93ee69d4507eee05b7693e5a781643e8339d4 (diff) |
Forgot worset feature
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@717 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/ff_wordset.cc')
-rw-r--r-- | decoder/ff_wordset.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/decoder/ff_wordset.cc b/decoder/ff_wordset.cc new file mode 100644 index 00000000..44468899 --- /dev/null +++ b/decoder/ff_wordset.cc @@ -0,0 +1,28 @@ +#include "ff_wordset.h" + +#include "fdict.h" +#include <sstream> +#include <iostream> + +using namespace std; + +void WordSet::TraversalFeaturesImpl(const SentenceMetadata& /*smeta*/ , + const Hypergraph::Edge& edge, + const vector<const void*>& /* ant_contexts */, + SparseVector<double>* features, + SparseVector<double>* /* estimated_features */, + void* /* context */) const { + + double addScore = 0.0; + for(std::vector<WordID>::const_iterator it = edge.rule_->e_.begin(); it != edge.rule_->e_.end(); ++it) { + + bool inVocab = (vocab_.find(*it) != vocab_.end()); + if(oovMode_ && !inVocab) { + addScore += 1.0; + } else if(!oovMode_ && inVocab) { + addScore += 1.0; + } + } + features->set_value(fid_, addScore); +} + |