mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 14:05:29 +03:00
Moved VW files to folder FF/VW, added VWFeature base class
This commit is contained in:
parent
320f824bee
commit
c3667f1c7f
@ -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);
|
||||
|
24
moses/FF/VW/VWFeatureBagOfWords.h
Normal file
24
moses/FF/VW/VWFeatureBagOfWords.h
Normal 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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
10
moses/FF/VW/VWFeatureBase.cpp
Normal file
10
moses/FF/VW/VWFeatureBase.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VWFeatureBase.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
std::vector<VWFeatureBase*> VWFeatureBase::s_features;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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() ;
|
@ -1,9 +0,0 @@
|
||||
|
||||
#include <string>
|
||||
#include "VWFeatureFeature.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
std::vector<VWFeatureFeature*> VWFeatureFeature::s_features;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user