diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-03-31 18:45:59 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-03-31 18:45:59 +0300 |
commit | 1a61e1405f881d0de001695de578e28d177c8781 (patch) | |
tree | 426e454722fc0f655f46ee079b623914b06864c8 /moses | |
parent | 633e7be8f069da1a30a8c97beb91f959896e0644 (diff) |
delete External FF. FF framework changes too fast to be able to keep this up-to-date
Diffstat (limited to 'moses')
-rw-r--r-- | moses/FF/ExternalFeature.cpp | 72 | ||||
-rw-r--r-- | moses/FF/ExternalFeature.h | 100 | ||||
-rw-r--r-- | moses/FF/Factory.cpp | 2 |
3 files changed, 0 insertions, 174 deletions
diff --git a/moses/FF/ExternalFeature.cpp b/moses/FF/ExternalFeature.cpp deleted file mode 100644 index 602971d2b..000000000 --- a/moses/FF/ExternalFeature.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "ExternalFeature.h" -#include <dlfcn.h> -#include <cstdlib> -#include <iostream> -#include "util/exception.hh" - -using namespace std; - -namespace Moses -{ -ExternalFeatureState::ExternalFeatureState(int stateSize, void *data) -{ - m_stateSize = stateSize; - m_data = malloc(stateSize); - memcpy(m_data, data, stateSize); -} - -void ExternalFeature::Load() -{ - string nparam = "testing"; - - if (m_path.size() < 1) { - UTIL_THROW2("External requires a path to a dynamic library"); - } - lib_handle = dlopen(m_path.c_str(), RTLD_LAZY); - if (!lib_handle) { - UTIL_THROW2("dlopen reports: " << dlerror() << ". Did you provide a full path to the dynamic library?";); - } - CdecFF* (*fn)(const string&) = - (CdecFF* (*)(const string&))(dlsym(lib_handle, "create_ff")); - if (!fn) { - UTIL_THROW2("dlsym reports: " << dlerror()); - } - ff_ext = (*fn)(nparam); - m_stateSize = ff_ext->StateSize(); - -} - -ExternalFeature::~ExternalFeature() -{ - delete ff_ext; - dlclose(lib_handle); -} - -void ExternalFeature::SetParameter(const std::string& key, const std::string& value) -{ - if (key == "path") { - m_path = value; - } else { - StatefulFeatureFunction::SetParameter(key, value); - } -} - -FFState* ExternalFeature::EvaluateWhenApplied( - const Hypothesis& cur_hypo, - const FFState* prev_state, - ScoreComponentCollection* accumulator) const -{ - return new ExternalFeatureState(m_stateSize); -} - -FFState* ExternalFeature::EvaluateWhenApplied( - const ChartHypothesis& /* cur_hypo */, - int /* featureID - used to index the state in the previous hypotheses */, - ScoreComponentCollection* accumulator) const -{ - return new ExternalFeatureState(m_stateSize); -} - - -} - diff --git a/moses/FF/ExternalFeature.h b/moses/FF/ExternalFeature.h deleted file mode 100644 index 6c0fb829e..000000000 --- a/moses/FF/ExternalFeature.h +++ /dev/null @@ -1,100 +0,0 @@ -#pragma once - -#include <string> -#include <cstring> -#include <cstdlib> -#include "StatefulFeatureFunction.h" -#include "FFState.h" - -namespace Moses -{ -class CdecFF; - -class ExternalFeatureState : public FFState -{ -protected: - int m_stateSize; - void *m_data; -public: - ExternalFeatureState(int stateSize) - :m_stateSize(stateSize) - ,m_data(NULL) { - } - ExternalFeatureState(int stateSize, void *data); - - ~ExternalFeatureState() { - free(m_data); - } - - int Compare(const FFState& other) const { - const ExternalFeatureState &otherFF = static_cast<const ExternalFeatureState&>(other); - int ret = memcmp(m_data, otherFF.m_data, m_stateSize); - return ret; - } -}; - -// copied from cdec -class ExternalFeature : public StatefulFeatureFunction -{ -public: - ExternalFeature(const std::string &line) - :StatefulFeatureFunction(line) { - ReadParameters(); - } - ~ExternalFeature(); - - void Load(); - - bool IsUseable(const FactorMask &mask) const { - return true; - } - - void SetParameter(const std::string& key, const std::string& value); - - void EvaluateInIsolation(const Phrase &source - , const TargetPhrase &targetPhrase - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection &estimatedFutureScore) const { - } - void EvaluateWithSourceContext(const InputType &input - , const InputPath &inputPath - , const TargetPhrase &targetPhrase - , const StackVec *stackVec - , ScoreComponentCollection &scoreBreakdown - , ScoreComponentCollection *estimatedFutureScore = NULL) const { - } - - void EvaluateTranslationOptionListWithSourceContext(const InputType &input - , const TranslationOptionList &translationOptionList) const { - } - - FFState* EvaluateWhenApplied( - const Hypothesis& cur_hypo, - const FFState* prev_state, - ScoreComponentCollection* accumulator) const; - - FFState* EvaluateWhenApplied( - const ChartHypothesis& /* cur_hypo */, - int /* featureID - used to index the state in the previous hypotheses */, - ScoreComponentCollection* accumulator) const; - - virtual const FFState* EmptyHypothesisState(const InputType &input) const { - return new ExternalFeatureState(m_stateSize); - } - -protected: - std::string m_path; - void* lib_handle; - CdecFF *ff_ext; - int m_stateSize; -}; - -class CdecFF -{ -public: - virtual ~CdecFF() {} - virtual int StateSize() const = 0; -}; - -} - diff --git a/moses/FF/Factory.cpp b/moses/FF/Factory.cpp index 218e458ff..80e4a4243 100644 --- a/moses/FF/Factory.cpp +++ b/moses/FF/Factory.cpp @@ -37,7 +37,6 @@ #include "moses/FF/PhrasePenalty.h" #include "moses/FF/OSM-Feature/OpSequenceModel.h" #include "moses/FF/ControlRecombination.h" -#include "moses/FF/ExternalFeature.h" #include "moses/FF/ConstrainedDecoding.h" #include "moses/FF/SoftSourceSyntacticConstraintsFeature.h" #include "moses/FF/CoveredReferenceFeature.h" @@ -229,7 +228,6 @@ FeatureRegistry::FeatureRegistry() MOSES_FNAME(ControlRecombination); MOSES_FNAME(ConstrainedDecoding); MOSES_FNAME(CoveredReferenceFeature); - MOSES_FNAME(ExternalFeature); MOSES_FNAME(SourceGHKMTreeInputMatchFeature); MOSES_FNAME(SoftSourceSyntacticConstraintsFeature); MOSES_FNAME(TreeStructureFeature); |