diff options
author | Ales Tamchyna <tamchyna@ufal.mff.cuni.cz> | 2015-02-16 12:59:55 +0300 |
---|---|---|
committer | Ales Tamchyna <tamchyna@ufal.mff.cuni.cz> | 2015-02-16 12:59:55 +0300 |
commit | a9926e7f4990b5a74b434fb99a8c8c753b8c8bbf (patch) | |
tree | 552fb3facb6d7d01ceb141a87bf79fea48bdc2b9 /moses | |
parent | 30ddd69de317b6e1fb3a88240ea038d0069d4b7f (diff) |
source bigram feature for VW
Diffstat (limited to 'moses')
-rw-r--r-- | moses/FF/VW/VWFeatureSourceBigrams.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/moses/FF/VW/VWFeatureSourceBigrams.h b/moses/FF/VW/VWFeatureSourceBigrams.h new file mode 100644 index 000000000..76827da0d --- /dev/null +++ b/moses/FF/VW/VWFeatureSourceBigrams.h @@ -0,0 +1,34 @@ +#pragma once + +#include <string> +#include "VWFeatureSource.h" + +namespace Moses +{ + +class VWFeatureSourceBagOfWords : public VWFeatureSource +{ +public: + VWFeatureSourceBagOfWords(const std::string &line) + : VWFeatureSource(line) { + ReadParameters(); + + // Call this last + VWFeatureBase::UpdateRegister(); + } + + void operator()(const InputType &input + , const InputPath &inputPath + , const WordsRange &sourceRange + , Discriminative::Classifier &classifier) const { + for (size_t i = 1; i < input.GetSize(); i++) { + classifier.AddLabelIndependentFeature("bigram^" + GetWord(input, i - 1) + "^" + GetWord(input, i)); + } + } + + virtual void SetParameter(const std::string& key, const std::string& value) { + VWFeatureSource::SetParameter(key, value); + } +}; + +} |