mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
implement Evaluate(inputpath, input) for chart translation options. Plumbing for lattice input
This commit is contained in:
parent
af74ee1968
commit
f676100328
@ -10,6 +10,8 @@ namespace Moses
|
||||
class TargetPhraseCollection;
|
||||
class WordsRange;
|
||||
class TargetPhrase;
|
||||
class InputPath;
|
||||
class InputType;
|
||||
|
||||
class ChartParserCallback
|
||||
{
|
||||
@ -21,6 +23,8 @@ public:
|
||||
virtual bool Empty() const = 0;
|
||||
|
||||
virtual void AddPhraseOOV(TargetPhrase &phrase, std::list<TargetPhraseCollection*> &waste_memory, const WordsRange &range) = 0;
|
||||
|
||||
virtual void Evaluate(const InputPath &inputPath, const InputType &input) = 0;
|
||||
};
|
||||
|
||||
} // namespace Moses
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "ChartTranslationOptions.h"
|
||||
#include "InputType.h"
|
||||
#include "InputPath.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
@ -8,5 +10,14 @@ ChartTranslationOption::ChartTranslationOption(const TargetPhrase &targetPhrase)
|
||||
{
|
||||
}
|
||||
|
||||
void ChartTranslationOption::Evaluate(const InputPath &inputPath, const InputType &input)
|
||||
{
|
||||
const std::vector<FeatureFunction*> &ffs = FeatureFunction::GetFeatureFunctions();
|
||||
|
||||
for (size_t i = 0; i < ffs.size(); ++i) {
|
||||
const FeatureFunction &ff = *ffs[i];
|
||||
ff.Evaluate(input, inputPath.GetPhrase(), m_scoreBreakdown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
namespace Moses
|
||||
{
|
||||
class TargetPhrase;
|
||||
class InputPath;
|
||||
class InputType;
|
||||
|
||||
class ChartTranslationOption
|
||||
{
|
||||
@ -23,6 +25,7 @@ public:
|
||||
return m_scoreBreakdown;
|
||||
}
|
||||
|
||||
void Evaluate(const InputPath &inputPath, const InputType &input);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -147,4 +147,13 @@ void ChartTranslationOptionList::ApplyThreshold()
|
||||
m_size = std::distance(m_collection.begin(), bound);
|
||||
}
|
||||
|
||||
void ChartTranslationOptionList::Evaluate(const InputPath &inputPath, const InputType &input)
|
||||
{
|
||||
CollType::iterator iter;
|
||||
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
|
||||
ChartTranslationOptions &transOpts = **iter;
|
||||
transOpts.Evaluate(inputPath, input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
|
||||
void Clear();
|
||||
void ApplyThreshold();
|
||||
void Evaluate(const InputPath &inputPath, const InputType &input);
|
||||
|
||||
private:
|
||||
typedef std::vector<ChartTranslationOptions*> CollType;
|
||||
|
@ -38,7 +38,7 @@ ChartTranslationOptions::ChartTranslationOptions(const TargetPhraseCollection &t
|
||||
const TargetPhrase *origTP = *iter;
|
||||
|
||||
boost::shared_ptr<ChartTranslationOption> ptr(new ChartTranslationOption(*origTP));
|
||||
m_targetPhraseCollection.push_back(ptr);
|
||||
m_collection.push_back(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,4 +64,14 @@ float ChartTranslationOptions::CalcEstimateOfBestScore(
|
||||
return estimateOfBestScore;
|
||||
}
|
||||
|
||||
void ChartTranslationOptions::Evaluate(const InputPath &inputPath, const InputType &input)
|
||||
{
|
||||
CollType::iterator iter;
|
||||
for (iter = m_collection.begin(); iter != m_collection.end(); ++iter) {
|
||||
ChartTranslationOption &transOpt = **iter;
|
||||
transOpt.Evaluate(inputPath, input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,8 @@
|
||||
namespace Moses
|
||||
{
|
||||
class ChartTranslationOption;
|
||||
class InputPath;
|
||||
class InputType;
|
||||
|
||||
/** Similar to a DottedRule, but contains a direct reference to a list
|
||||
* of translations and provdes an estimate of the best score. For a specific range in the input sentence
|
||||
@ -63,7 +65,7 @@ public:
|
||||
|
||||
//! @todo isn't the translation suppose to just contain 1 target phrase, not a whole collection of them?
|
||||
const CollType &GetTargetPhrases() const {
|
||||
return m_targetPhraseCollection;
|
||||
return m_collection;
|
||||
}
|
||||
|
||||
//! the range in the source sentence this translation option covers
|
||||
@ -79,10 +81,12 @@ public:
|
||||
return m_estimateOfBestScore;
|
||||
}
|
||||
|
||||
void Evaluate(const InputPath &inputPath, const InputType &input);
|
||||
|
||||
private:
|
||||
|
||||
StackVec m_stackVec; //! vector of hypothesis list!
|
||||
CollType m_targetPhraseCollection;
|
||||
CollType m_collection;
|
||||
|
||||
const WordsRange *m_wordsRange;
|
||||
float m_estimateOfBestScore;
|
||||
|
@ -97,6 +97,10 @@ public:
|
||||
return vertex.BestChild();
|
||||
}
|
||||
|
||||
void Evaluate(const InputPath &inputPath, const InputType &input)
|
||||
{
|
||||
// TODO for input lattice
|
||||
}
|
||||
private:
|
||||
lm::WordIndex Convert(const Word &word) const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user