mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 04:43:03 +03:00
delete ChangeSource(). Not used
This commit is contained in:
parent
2f04d4a56e
commit
efdb8566b1
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="all" Database="all.tags">
|
||||
<Project Name="manual-label" Path="manual-label/manual-label.project" Active="No"/>
|
||||
<Project Name="extract" Path="extract/extract.project" Active="No"/>
|
||||
<Project Name="util" Path="util/util.project" Active="No"/>
|
||||
<Project Name="extract-mixed-syntax" Path="extract-mixed-syntax/extract-mixed-syntax.project" Active="No"/>
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Project Name="moses" InternalType="Library">
|
||||
<Plugins>
|
||||
<Plugin Name="qmake">
|
||||
<![CDATA[00010001N0005Debug000000000000]]>
|
||||
</Plugin>
|
||||
<Plugin Name="CMakePlugin">
|
||||
<![CDATA[[{
|
||||
"name": "Debug",
|
||||
@ -13,9 +16,6 @@
|
||||
"parentProject": ""
|
||||
}]]]>
|
||||
</Plugin>
|
||||
<Plugin Name="qmake">
|
||||
<![CDATA[00010001N0005Debug000000000000]]>
|
||||
</Plugin>
|
||||
</Plugins>
|
||||
<VirtualDirectory Name="TranslationModel">
|
||||
<VirtualDirectory Name="UG">
|
||||
@ -531,8 +531,6 @@
|
||||
<File Name="../../../moses/FF/RuleScope.h"/>
|
||||
<File Name="../../../moses/FF/SetSourcePhrase.cpp"/>
|
||||
<File Name="../../../moses/FF/SetSourcePhrase.h"/>
|
||||
<File Name="../../../moses/FF/SkeletonChangeInput.cpp"/>
|
||||
<File Name="../../../moses/FF/SkeletonChangeInput.h"/>
|
||||
<File Name="../../../moses/FF/SkeletonStatefulFF.cpp"/>
|
||||
<File Name="../../../moses/FF/SkeletonStatefulFF.h"/>
|
||||
<File Name="../../../moses/FF/SkeletonStatelessFF.cpp"/>
|
||||
|
@ -151,9 +151,6 @@ int main(int argc, char** argv)
|
||||
ResetUserTime();
|
||||
}
|
||||
|
||||
InputType* foo = source.get();
|
||||
FeatureFunction::CallChangeSource(foo);
|
||||
|
||||
// set up task of training one sentence
|
||||
boost::shared_ptr<TrainingTask> task;
|
||||
task = TrainingTask::create(source, ioWrapper);
|
||||
|
@ -118,8 +118,6 @@ string SimpleTranslationInterface::translate(const string &inputString)
|
||||
ResetUserTime();
|
||||
}
|
||||
|
||||
FeatureFunction::CallChangeSource(&*source);
|
||||
|
||||
// set up task of translating one sentence
|
||||
boost::shared_ptr<TranslationTask> task
|
||||
= TranslationTask::create(source, ioWrapper);
|
||||
@ -223,8 +221,6 @@ batch_run()
|
||||
while ((source = ioWrapper->ReadInput()) != NULL) {
|
||||
IFVERBOSE(1) ResetUserTime();
|
||||
|
||||
FeatureFunction::CallChangeSource(source.get());
|
||||
|
||||
// set up task of translating one sentence
|
||||
boost::shared_ptr<TranslationTask>
|
||||
task = TranslationTask::create(source, ioWrapper);
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include "moses/LM/SkeletonLM.h"
|
||||
#include "moses/FF/SkeletonTranslationOptionListFeature.h"
|
||||
#include "moses/LM/BilingualLM.h"
|
||||
#include "SkeletonChangeInput.h"
|
||||
#include "moses/TranslationModel/SkeletonPT.h"
|
||||
#include "moses/Syntax/InputWeightFF.h"
|
||||
#include "moses/Syntax/RuleTableFF.h"
|
||||
@ -268,7 +267,6 @@ FeatureRegistry::FeatureRegistry()
|
||||
MOSES_FNAME(SkeletonStatelessFF);
|
||||
MOSES_FNAME(SkeletonStatefulFF);
|
||||
MOSES_FNAME(SkeletonLM);
|
||||
MOSES_FNAME(SkeletonChangeInput);
|
||||
MOSES_FNAME(SkeletonTranslationOptionListFeature);
|
||||
MOSES_FNAME(SkeletonPT);
|
||||
|
||||
|
@ -38,20 +38,6 @@ void FeatureFunction::Destroy()
|
||||
RemoveAllInColl(s_staticColl);
|
||||
}
|
||||
|
||||
// The original declaration as
|
||||
// void FeatureFunction::CallChangeSource(InputType *&input)
|
||||
// had me a bit perplexed. Would you really want to allow
|
||||
// any feature function to replace the InputType behind the
|
||||
// back of the others? And change what the vector is pointing to?
|
||||
|
||||
void FeatureFunction::CallChangeSource(InputType * const&input)
|
||||
{
|
||||
for (size_t i = 0; i < s_staticColl.size(); ++i) {
|
||||
const FeatureFunction &ff = *s_staticColl[i];
|
||||
ff.ChangeSource(input);
|
||||
}
|
||||
}
|
||||
|
||||
void FeatureFunction::SetupAll(TranslationTask const& ttask)
|
||||
{
|
||||
BOOST_FOREACH(FeatureFunction* ff, s_staticColl)
|
||||
|
@ -62,9 +62,6 @@ public:
|
||||
static FeatureFunction &FindFeatureFunction(const std::string& name);
|
||||
static void Destroy();
|
||||
|
||||
static void CallChangeSource(InputType * const&input);
|
||||
// see my note in FeatureFunction.cpp --- UG
|
||||
|
||||
FeatureFunction(const std::string &line, bool initializeNow);
|
||||
FeatureFunction(size_t numScoreComponents, const std::string &line);
|
||||
virtual bool IsStateless() const = 0;
|
||||
@ -156,9 +153,6 @@ public:
|
||||
ScoreComponentCollection& scoreBreakdown,
|
||||
ScoreComponentCollection& estimatedFutureScore) const = 0;
|
||||
|
||||
// override this method if you want to change the input before decoding
|
||||
virtual void ChangeSource(InputType * const&input) const { }
|
||||
|
||||
// for context-dependent processing
|
||||
static void SetupAll(TranslationTask const& task);
|
||||
virtual void Setup(TranslationTask const& task) const { };
|
||||
|
@ -1,96 +0,0 @@
|
||||
#include <vector>
|
||||
#include "SkeletonChangeInput.h"
|
||||
#include "moses/ScoreComponentCollection.h"
|
||||
#include "moses/TargetPhrase.h"
|
||||
#include "moses/Sentence.h"
|
||||
#include "moses/FactorCollection.h"
|
||||
#include "util/exception.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
SkeletonChangeInput::SkeletonChangeInput(const std::string &line)
|
||||
:StatelessFeatureFunction(2, line)
|
||||
{
|
||||
ReadParameters();
|
||||
}
|
||||
|
||||
void SkeletonChangeInput::EvaluateInIsolation(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const
|
||||
{
|
||||
// dense scores
|
||||
vector<float> newScores(m_numScoreComponents);
|
||||
newScores[0] = 1.5;
|
||||
newScores[1] = 0.3;
|
||||
scoreBreakdown.PlusEquals(this, newScores);
|
||||
|
||||
// sparse scores
|
||||
scoreBreakdown.PlusEquals(this, "sparse-name", 2.4);
|
||||
|
||||
}
|
||||
|
||||
void SkeletonChangeInput::EvaluateWithSourceContext(const InputType &input
|
||||
, const InputPath &inputPath
|
||||
, const TargetPhrase &targetPhrase
|
||||
, const StackVec *stackVec
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection *estimatedFutureScore) const
|
||||
{
|
||||
if (targetPhrase.GetNumNonTerminals()) {
|
||||
vector<float> newScores(m_numScoreComponents);
|
||||
newScores[0] = - std::numeric_limits<float>::infinity();
|
||||
scoreBreakdown.PlusEquals(this, newScores);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SkeletonChangeInput::EvaluateTranslationOptionListWithSourceContext(const InputType &input
|
||||
, const TranslationOptionList &translationOptionList) const
|
||||
{}
|
||||
|
||||
void SkeletonChangeInput::EvaluateWhenApplied(const Hypothesis& hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
|
||||
void SkeletonChangeInput::EvaluateWhenApplied(const ChartHypothesis &hypo,
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{}
|
||||
|
||||
void SkeletonChangeInput::ChangeSource(InputType* const& input) const
|
||||
{
|
||||
// add factor[1] to each word. Created from first 4 letter of factor[0]
|
||||
|
||||
Sentence *sentence = dynamic_cast<Sentence*>(input);
|
||||
UTIL_THROW_IF2(sentence == NULL, "Not a sentence input");
|
||||
|
||||
FactorCollection &fc = FactorCollection::Instance();
|
||||
|
||||
size_t size = sentence->GetSize();
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
Word &word = sentence->Phrase::GetWord(i);
|
||||
const Factor *factor0 = word[0];
|
||||
|
||||
std::string str = factor0->GetString().as_string();
|
||||
if (str.length() > 4) {
|
||||
str = str.substr(0, 4);
|
||||
}
|
||||
|
||||
const Factor *factor1 = fc.AddFactor(str);
|
||||
word.SetFactor(1, factor1);
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletonChangeInput::SetParameter(const std::string& key, const std::string& value)
|
||||
{
|
||||
if (key == "arg") {
|
||||
// set value here
|
||||
} else {
|
||||
StatelessFeatureFunction::SetParameter(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "StatelessFeatureFunction.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
class SkeletonChangeInput : public StatelessFeatureFunction
|
||||
{
|
||||
public:
|
||||
SkeletonChangeInput(const std::string &line);
|
||||
|
||||
bool IsUseable(const FactorMask &mask) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
void EvaluateInIsolation(const Phrase &source
|
||||
, const TargetPhrase &targetPhrase
|
||||
, ScoreComponentCollection &scoreBreakdown
|
||||
, ScoreComponentCollection &estimatedFutureScore) const;
|
||||
|
||||
void ChangeSource(InputType* const&input) 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;
|
||||
|
||||
void EvaluateWhenApplied(const Hypothesis& hypo,
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
void EvaluateWhenApplied(const ChartHypothesis &hypo,
|
||||
ScoreComponentCollection* accumulator) const;
|
||||
|
||||
void SetParameter(const std::string& key, const std::string& value);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user