summaryrefslogtreecommitdiff
path: root/decoder/ff_wordset.cc
blob: 44468899843aa18f1dd42bde368b7154d44c660a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
}