mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 21:42:19 +03:00
target (internal) bigrams for VW
This commit is contained in:
parent
b05fc4c9bc
commit
a46daa1938
@ -67,10 +67,11 @@
|
|||||||
#ifdef HAVE_VW
|
#ifdef HAVE_VW
|
||||||
#include "moses/FF/VW/VW.h"
|
#include "moses/FF/VW/VW.h"
|
||||||
#include "moses/FF/VW/VWFeatureSourceBagOfWords.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/VWFeatureSourceIndicator.h"
|
||||||
#include "moses/FF/VW/VWFeatureSourcePhraseInternal.h"
|
#include "moses/FF/VW/VWFeatureSourcePhraseInternal.h"
|
||||||
#include "moses/FF/VW/VWFeatureSourceWindow.h"
|
#include "moses/FF/VW/VWFeatureSourceWindow.h"
|
||||||
|
#include "moses/FF/VW/VWFeatureTargetBigrams.h"
|
||||||
#include "moses/FF/VW/VWFeatureTargetIndicator.h"
|
#include "moses/FF/VW/VWFeatureTargetIndicator.h"
|
||||||
#include "moses/FF/VW/VWFeatureSourceExternalFeatures.h"
|
#include "moses/FF/VW/VWFeatureSourceExternalFeatures.h"
|
||||||
#include "moses/FF/VW/VWFeatureTargetPhraseInternal.h"
|
#include "moses/FF/VW/VWFeatureTargetPhraseInternal.h"
|
||||||
@ -250,10 +251,11 @@ FeatureRegistry::FeatureRegistry()
|
|||||||
#ifdef HAVE_VW
|
#ifdef HAVE_VW
|
||||||
MOSES_FNAME(VW);
|
MOSES_FNAME(VW);
|
||||||
MOSES_FNAME(VWFeatureSourceBagOfWords);
|
MOSES_FNAME(VWFeatureSourceBagOfWords);
|
||||||
MOSES_FNAME(VWFeatureSourceBigram);
|
MOSES_FNAME(VWFeatureSourceBigrams);
|
||||||
MOSES_FNAME(VWFeatureSourceIndicator);
|
MOSES_FNAME(VWFeatureSourceIndicator);
|
||||||
MOSES_FNAME(VWFeatureSourcePhraseInternal);
|
MOSES_FNAME(VWFeatureSourcePhraseInternal);
|
||||||
MOSES_FNAME(VWFeatureSourceWindow);
|
MOSES_FNAME(VWFeatureSourceWindow);
|
||||||
|
MOSES_FNAME(VWFeatureTargetBigrams);
|
||||||
MOSES_FNAME(VWFeatureTargetPhraseInternal);
|
MOSES_FNAME(VWFeatureTargetPhraseInternal);
|
||||||
MOSES_FNAME(VWFeatureTargetIndicator);
|
MOSES_FNAME(VWFeatureTargetIndicator);
|
||||||
MOSES_FNAME(VWFeatureSourceExternalFeatures);
|
MOSES_FNAME(VWFeatureSourceExternalFeatures);
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
namespace Moses
|
namespace Moses
|
||||||
{
|
{
|
||||||
|
|
||||||
class VWFeatureSourceBagOfWords : public VWFeatureSource
|
class VWFeatureSourceBigrams : public VWFeatureSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VWFeatureSourceBagOfWords(const std::string &line)
|
VWFeatureSourceBigrams(const std::string &line)
|
||||||
: VWFeatureSource(line) {
|
: VWFeatureSource(line) {
|
||||||
ReadParameters();
|
ReadParameters();
|
||||||
|
|
||||||
|
33
moses/FF/VW/VWFeatureTargetBigrams.h
Normal file
33
moses/FF/VW/VWFeatureTargetBigrams.h
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user