Moved VW files to folder FF/VW, added VWFeature base class

This commit is contained in:
Marcin Junczys-Dowmunt 2015-01-06 17:00:26 +01:00
parent 320f824bee
commit c3667f1c7f
9 changed files with 52 additions and 32 deletions

View File

@ -63,8 +63,8 @@
#include "moses/TranslationModel/SkeletonPT.h"
#include "moses/Syntax/RuleTableFF.h"
#include "moses/FF/VWFeatureDummy.h"
#include "moses/FF/VWFeatureFeature.h"
#include "moses/FF/VW/VWFeatureDummy.h"
#include "moses/FF/VW/VWFeatureBagOfWords.h"
#ifdef HAVE_CMPH
#include "moses/TranslationModel/CompactPT/PhraseDictionaryCompact.h"
@ -236,7 +236,7 @@ FeatureRegistry::FeatureRegistry()
MOSES_FNAME(SkeletonPT);
MOSES_FNAME(VWFeatureDummy);
MOSES_FNAME(VWFeatureFeature);
MOSES_FNAME(VWFeatureBagOfWords);
#ifdef HAVE_CMPH
MOSES_FNAME(PhraseDictionaryCompact);

View File

@ -0,0 +1,24 @@
#pragma once
#include <string>
#include "VWFeatureBase.h"
namespace Moses
{
class VWFeatureBagOfWords : public VWFeatureBase
{
public:
VWFeatureBagOfWords(const std::string &line)
: VWFeatureBase(line)
{}
void operator()(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase) const
{
std::cerr << GetScoreProducerDescription() << " got TargetPhrase: " << targetPhrase << std::endl;
}
};
}

View File

@ -0,0 +1,10 @@
#include <string>
#include "VWFeatureBase.h"
namespace Moses
{
std::vector<VWFeatureBase*> VWFeatureBase::s_features;
}

View File

@ -1,17 +1,15 @@
#pragma once
#include <string>
#include "StatelessFeatureFunction.h"
#include "moses/FF/StatelessFeatureFunction.h"
namespace Moses
{
// BE IGNORED BY STATIC DATA.
class VWFeatureFeature : public StatelessFeatureFunction
class VWFeatureBase : public StatelessFeatureFunction
{
public:
VWFeatureFeature(const std::string &line)
VWFeatureBase(const std::string &line)
:StatelessFeatureFunction(0, line)
{
ReadParameters();
@ -43,23 +41,19 @@ class VWFeatureFeature : public StatelessFeatureFunction
ScoreComponentCollection* accumulator) const {}
void SetParameter(const std::string& key, const std::string& value)
{
}
{}
void DoSomething(const InputType &input
virtual void operator()(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase) {
std::cerr << GetScoreProducerDescription() << " got TargetPhrase: " << targetPhrase << std::endl;
}
, const TargetPhrase &targetPhrase) const = 0;
static std::vector<VWFeatureFeature*>& GetFeatures() {
static std::vector<VWFeatureBase*>& GetFeatures() {
return s_features;
}
private:
static std::vector<VWFeatureFeature*> s_features;
};
static std::vector<VWFeatureBase*> s_features;
};
}

View File

@ -1,9 +1,9 @@
#pragma once
#include <string>
#include "StatelessFeatureFunction.h"
#include "moses/FF/StatelessFeatureFunction.h"
#include "VWFeatureFeature.h"
#include "VWFeatureBase.h"
namespace Moses
{
@ -38,7 +38,7 @@ public:
void EvaluateTranslationOptionListWithSourceContext(const InputType &input
, const TranslationOptionList &translationOptionList) const
{
std::vector<VWFeatureFeature*>& features = VWFeatureFeature::GetFeatures();
std::vector<VWFeatureBase*>& features = VWFeatureBase::GetFeatures();
TranslationOptionList::const_iterator iterTransOpt;
for(iterTransOpt = translationOptionList.begin() ;
@ -47,7 +47,7 @@ public:
TranslationOption &transOpt = **iterTransOpt;
for(size_t i = 0; i < features.size(); ++i)
features[i]->DoSomething(input, transOpt.GetInputPath(), transOpt.GetTargetPhrase());
(*features[i])(input, transOpt.GetInputPath(), transOpt.GetTargetPhrase());
}
for(iterTransOpt = translationOptionList.begin() ;

View File

@ -1,9 +0,0 @@
#include <string>
#include "VWFeatureFeature.h"
namespace Moses
{
std::vector<VWFeatureFeature*> VWFeatureFeature::s_features;
}

View File

@ -83,6 +83,7 @@ lib moses :
FF/*.cpp
FF/bilingual-lm/*.cpp
FF/OSM-Feature/*.cpp
FF/VW/*.cpp
FF/LexicalReordering/*.cpp
PP/*.cpp
: #exceptions