diff options
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); +} + |