mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-05 02:22:21 +03:00
integrate compact lex RO
This commit is contained in:
parent
6f25f43cf9
commit
4a36aa59c8
@ -53,7 +53,7 @@ public:
|
||||
Scores *estimatedScores) const = 0;
|
||||
|
||||
virtual void
|
||||
EvaluateAfterTablePruning(const TargetPhrases &tps) const
|
||||
EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const
|
||||
{}
|
||||
|
||||
// clean up temporary memory, called after processing each sentence
|
||||
|
@ -189,10 +189,11 @@ FeatureFunctions::EvaluateInIsolation(MemPool &pool, const System &system,
|
||||
targetPhrase.SetEstimatedScore(estimatedScores.GetTotalScore());
|
||||
}
|
||||
|
||||
void FeatureFunctions::EvaluateAfterTablePruning(const TargetPhrases &tps) const
|
||||
void FeatureFunctions::EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const
|
||||
{
|
||||
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) {
|
||||
ff->EvaluateAfterTablePruning(tps); }
|
||||
ff->EvaluateAfterTablePruning(pool, tps, sourcePhrase);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
// the pool here must be the system pool if the rule was loaded during load, or the mgr if it was loaded on demand
|
||||
void EvaluateInIsolation(MemPool &pool, const System &system,
|
||||
const Phrase &source, TargetPhrase &targetPhrase) const;
|
||||
void EvaluateAfterTablePruning(const TargetPhrases &tps) const;
|
||||
void EvaluateAfterTablePruning(MemPool &pool, const TargetPhrases &tps, const Phrase &sourcePhrase) const;
|
||||
|
||||
protected:
|
||||
std::vector<const FeatureFunction*> m_featureFunctions;
|
||||
|
@ -140,18 +140,22 @@ void LexicalReordering::EvaluateInIsolation(MemPool &pool,
|
||||
{
|
||||
}
|
||||
|
||||
void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrases &tps) const
|
||||
void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool,
|
||||
const TargetPhrases &tps,
|
||||
const Phrase &sourcePhrase) const
|
||||
{
|
||||
BOOST_FOREACH(const TargetPhrase *tp, tps) {
|
||||
EvaluateAfterTablePruning(*tp);
|
||||
EvaluateAfterTablePruning(pool, *tp, sourcePhrase);
|
||||
}
|
||||
}
|
||||
|
||||
void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrase &targetPhrase) const
|
||||
void LexicalReordering::EvaluateAfterTablePruning(MemPool &pool,
|
||||
const TargetPhrase &targetPhrase,
|
||||
const Phrase &sourcePhrase) const
|
||||
{
|
||||
/*
|
||||
if (m_compactModel) {
|
||||
const Values values = m_compactModel->GetScore(source, targetPhrase, *m_blank);
|
||||
const Values values = m_compactModel->GetScore(sourcePhrase, targetPhrase, *m_blank);
|
||||
if (values.size()) {
|
||||
assert(values.size() == 6);
|
||||
SCORE *scoreArr = pool.Allocate<SCORE>(6);
|
||||
@ -168,7 +172,7 @@ void LexicalReordering::EvaluateAfterTablePruning(const TargetPhrase &targetPhra
|
||||
assert(m_coll);
|
||||
|
||||
// cache data in target phrase
|
||||
const Values *values = GetValues(source, targetPhrase);
|
||||
const Values *values = GetValues(sourcePhrase, targetPhrase);
|
||||
if (values) {
|
||||
SCORE *scoreArr = pool.Allocate<SCORE>(6);
|
||||
for (size_t i = 0; i < 6; ++i) {
|
||||
|
@ -45,7 +45,9 @@ public:
|
||||
Scores *estimatedScores) const;
|
||||
|
||||
virtual void
|
||||
EvaluateAfterTablePruning(const TargetPhrases &tps) const;
|
||||
EvaluateAfterTablePruning(MemPool &pool,
|
||||
const TargetPhrases &tps,
|
||||
const Phrase &sourcePhrase) const;
|
||||
|
||||
virtual void EvaluateWhenApplied(const Manager &mgr,
|
||||
const Hypothesis &hypo,
|
||||
@ -60,7 +62,9 @@ protected:
|
||||
FactorList m_FactorsC;
|
||||
|
||||
virtual void
|
||||
EvaluateAfterTablePruning(const TargetPhrase &targetPhrase) const;
|
||||
EvaluateAfterTablePruning(MemPool &pool,
|
||||
const TargetPhrase &targetPhrase,
|
||||
const Phrase &sourcePhrase) const;
|
||||
|
||||
// COMPACT MODEL
|
||||
LexicalReorderingTableCompact *m_compactModel;
|
||||
|
@ -39,6 +39,7 @@ PhraseTableMemory::Node &PhraseTableMemory::Node::AddRule(PhraseImpl &source, Ta
|
||||
if (pos == source.GetSize()) {
|
||||
if (m_unsortedTPS == NULL) {
|
||||
m_unsortedTPS = new std::vector<TargetPhrase*>();
|
||||
m_source = &source;
|
||||
}
|
||||
|
||||
m_unsortedTPS->push_back(target);
|
||||
@ -88,7 +89,7 @@ void PhraseTableMemory::Node::SortAndPrune(size_t tableLimit, MemPool &pool, Sys
|
||||
}
|
||||
|
||||
m_targetPhrases->SortAndPrune(tableLimit);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(*m_targetPhrases);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(system.systemPool, *m_targetPhrases, *m_source);
|
||||
|
||||
delete m_unsortedTPS;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ class PhraseTableMemory : public PhraseTable
|
||||
typedef boost::unordered_map<Word, Node, UnorderedComparer<Word>, UnorderedComparer<Word> > Children;
|
||||
Children m_children;
|
||||
TargetPhrases *m_targetPhrases;
|
||||
PhraseImpl *m_source;
|
||||
std::vector<TargetPhrase*> *m_unsortedTPS;
|
||||
|
||||
Node &AddRule(PhraseImpl &source, TargetPhrase *target, size_t pos);
|
||||
|
@ -126,7 +126,7 @@ TargetPhrases* ProbingPT::CreateTargetPhrase(MemPool &pool, const System &system
|
||||
}
|
||||
|
||||
tps->SortAndPrune(m_tableLimit);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(*tps);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(pool, *tps, sourcePhrase);
|
||||
}
|
||||
else {
|
||||
assert(query_result.second.size() == 0);
|
||||
|
@ -78,7 +78,7 @@ TargetPhrases *UnknownWordPenalty::Lookup(const Manager &mgr, MemPool &pool, Inp
|
||||
system.featureFunctions.EvaluateInIsolation(memPool, system, source, *target);
|
||||
|
||||
tps->AddTargetPhrase(*target);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(*tps);
|
||||
system.featureFunctions.EvaluateAfterTablePruning(memPool, *tps, source);
|
||||
|
||||
return tps;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user