Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/moses
diff options
context:
space:
mode:
authorAles Tamchyna <tamchyna@ufal.mff.cuni.cz>2015-02-16 13:36:16 +0300
committerAles Tamchyna <tamchyna@ufal.mff.cuni.cz>2015-02-16 13:36:16 +0300
commita46daa19383243b01426b59d87d11ea06d7a468e (patch)
tree808a7592fbafd5c04aca7a956d865aaaf319c99c /moses
parentb05fc4c9bcdd36171a4206749cc080d71c50271d (diff)
target (internal) bigrams for VW
Diffstat (limited to 'moses')
-rw-r--r--moses/FF/Factory.cpp6
-rw-r--r--moses/FF/VW/VWFeatureSourceBigrams.h4
-rw-r--r--moses/FF/VW/VWFeatureTargetBigrams.h33
3 files changed, 39 insertions, 4 deletions
diff --git a/moses/FF/Factory.cpp b/moses/FF/Factory.cpp
index 2fbd1d304..525808f98 100644
--- a/moses/FF/Factory.cpp
+++ b/moses/FF/Factory.cpp
@@ -67,10 +67,11 @@
#ifdef HAVE_VW
#include "moses/FF/VW/VW.h"
#include "moses/FF/VW/VWFeatureSourceBagOfWords.h"
-#include "moses/FF/VW/VWFeatureSourceBigram.h"
+#include "moses/FF/VW/VWFeatureSourceBigrams.h"
#include "moses/FF/VW/VWFeatureSourceIndicator.h"
#include "moses/FF/VW/VWFeatureSourcePhraseInternal.h"
#include "moses/FF/VW/VWFeatureSourceWindow.h"
+#include "moses/FF/VW/VWFeatureTargetBigrams.h"
#include "moses/FF/VW/VWFeatureTargetIndicator.h"
#include "moses/FF/VW/VWFeatureSourceExternalFeatures.h"
#include "moses/FF/VW/VWFeatureTargetPhraseInternal.h"
@@ -250,10 +251,11 @@ FeatureRegistry::FeatureRegistry()
#ifdef HAVE_VW
MOSES_FNAME(VW);
MOSES_FNAME(VWFeatureSourceBagOfWords);
- MOSES_FNAME(VWFeatureSourceBigram);
+ MOSES_FNAME(VWFeatureSourceBigrams);
MOSES_FNAME(VWFeatureSourceIndicator);
MOSES_FNAME(VWFeatureSourcePhraseInternal);
MOSES_FNAME(VWFeatureSourceWindow);
+ MOSES_FNAME(VWFeatureTargetBigrams);
MOSES_FNAME(VWFeatureTargetPhraseInternal);
MOSES_FNAME(VWFeatureTargetIndicator);
MOSES_FNAME(VWFeatureSourceExternalFeatures);
diff --git a/moses/FF/VW/VWFeatureSourceBigrams.h b/moses/FF/VW/VWFeatureSourceBigrams.h
index 76827da0d..9d853d938 100644
--- a/moses/FF/VW/VWFeatureSourceBigrams.h
+++ b/moses/FF/VW/VWFeatureSourceBigrams.h
@@ -6,10 +6,10 @@
namespace Moses
{
-class VWFeatureSourceBagOfWords : public VWFeatureSource
+class VWFeatureSourceBigrams : public VWFeatureSource
{
public:
- VWFeatureSourceBagOfWords(const std::string &line)
+ VWFeatureSourceBigrams(const std::string &line)
: VWFeatureSource(line) {
ReadParameters();
diff --git a/moses/FF/VW/VWFeatureTargetBigrams.h b/moses/FF/VW/VWFeatureTargetBigrams.h
new file mode 100644
index 000000000..6f3f35270
--- /dev/null
+++ b/moses/FF/VW/VWFeatureTargetBigrams.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <string>
+#include "VWFeatureTarget.h"
+
+namespace Moses
+{
+
+class VWFeatureTargetBigrams : public VWFeatureTarget
+{
+public:
+ VWFeatureTargetBigrams(const std::string &line)
+ : VWFeatureTarget(line) {
+ ReadParameters();
+
+ VWFeatureBase::UpdateRegister();
+ }
+
+ void operator()(const InputType &input
+ , const InputPath &inputPath
+ , const TargetPhrase &targetPhrase
+ , Discriminative::Classifier &classifier) const {
+ for (size_t i = 1; i < targetPhrase.GetSize(); i++) {
+ classifier.AddLabelDependentFeature("tbigram^" + GetWord(targetPhrase, i - 1) + "^" + GetWord(targetPhrase, i));
+ }
+ }
+
+ virtual void SetParameter(const std::string& key, const std::string& value) {
+ VWFeatureTarget::SetParameter(key, value);
+ }
+};
+
+}