Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Germann <Ulrich.Germann@gmail.com>2015-08-07 00:52:34 +0300
committerUlrich Germann <Ulrich.Germann@gmail.com>2015-08-07 00:52:34 +0300
commit6c1d9e2431a1dbc270ea5ab401f47c2c32621103 (patch)
treefcab703afdd8205b15f3de2a19d59cabc5a7ca6a /moses/LatticeMBR.cpp
parent524109e2cabe5bd3ac693d3187e439885484a8c7 (diff)
More reorganisation of options.
Diffstat (limited to 'moses/LatticeMBR.cpp')
-rw-r--r--moses/LatticeMBR.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/moses/LatticeMBR.cpp b/moses/LatticeMBR.cpp
index b6fa14757..46fb16242 100644
--- a/moses/LatticeMBR.cpp
+++ b/moses/LatticeMBR.cpp
@@ -490,13 +490,18 @@ bool Edge::operator< (const Edge& compare ) const
ostream& operator<< (ostream& out, const Edge& edge)
{
- out << "Head: " << edge.m_headNode->GetId() << ", Tail: " << edge.m_tailNode->GetId() << ", Score: " << edge.m_score << ", Phrase: " << edge.m_targetPhrase << endl;
+ out << "Head: " << edge.m_headNode->GetId()
+ << ", Tail: " << edge.m_tailNode->GetId()
+ << ", Score: " << edge.m_score
+ << ", Phrase: " << edge.m_targetPhrase << endl;
return out;
}
bool ascendingCoverageCmp(const Hypothesis* a, const Hypothesis* b)
{
- return a->GetWordsBitmap().GetNumWordsCovered() < b->GetWordsBitmap().GetNumWordsCovered();
+ return (a->GetWordsBitmap().GetNumWordsCovered()
+ <
+ b->GetWordsBitmap().GetNumWordsCovered());
}
void getLatticeMBRNBest(const Manager& manager, const TrellisPathList& nBestList,
@@ -509,15 +514,20 @@ void getLatticeMBRNBest(const Manager& manager, const TrellisPathList& nBestList
std::map < const Hypothesis*, set <const Hypothesis*> > outgoingHyps;
map<const Hypothesis*, vector<Edge> > incomingEdges;
vector< float> estimatedScores;
- manager.GetForwardBackwardSearchGraph(&connected, &connectedList, &outgoingHyps, &estimatedScores);
- pruneLatticeFB(connectedList, outgoingHyps, incomingEdges, estimatedScores, manager.GetBestHypothesis(), staticData.GetLatticeMBRPruningFactor(),staticData.GetMBRScale());
+ manager.GetForwardBackwardSearchGraph(&connected, &connectedList,
+ &outgoingHyps, &estimatedScores);
+ LMBR_Options const& lmbr = manager.options().lmbr;
+ MBR_Options const& mbr = manager.options().mbr;
+ pruneLatticeFB(connectedList, outgoingHyps, incomingEdges, estimatedScores,
+ manager.GetBestHypothesis(), lmbr.pruning_factor, mbr.scale);
calcNgramExpectations(connectedList, incomingEdges, ngramPosteriors,true);
- vector<float> mbrThetas = staticData.GetLatticeMBRThetas();
- float p = staticData.GetLatticeMBRPrecision();
- float r = staticData.GetLatticeMBRPRatio();
- float mapWeight = staticData.GetLatticeMBRMapWeight();
- if (mbrThetas.size() == 0) { //thetas not specified on the command line, use p and r instead
+ vector<float> mbrThetas = lmbr.theta;
+ float p = lmbr.precision;
+ float r = lmbr.ratio;
+ float mapWeight = lmbr.map_weight;
+ if (mbrThetas.size() == 0) {
+ // thetas were not specified on the command line, so use p and r instead
mbrThetas.push_back(-1); //Theta 0
mbrThetas.push_back(1/(bleu_order*p));
for (size_t i = 2; i <= bleu_order; ++i) {
@@ -537,7 +547,7 @@ void getLatticeMBRNBest(const Manager& manager, const TrellisPathList& nBestList
for (iter = nBestList.begin() ; iter != nBestList.end() ; ++iter, ++ctr) {
const TrellisPath &path = **iter;
solutions.push_back(LatticeMBRSolution(path,iter==nBestList.begin()));
- solutions.back().CalcScore(ngramPosteriors,mbrThetas,mapWeight);
+ solutions.back().CalcScore(ngramPosteriors, mbrThetas, mapWeight);
sort(solutions.begin(), solutions.end(), comparator);
while (solutions.size() > n) {
solutions.pop_back();
@@ -568,7 +578,10 @@ const TrellisPath doConsensusDecoding(const Manager& manager, const TrellisPathL
map<const Hypothesis*, vector<Edge> > incomingEdges;
vector< float> estimatedScores;
manager.GetForwardBackwardSearchGraph(&connected, &connectedList, &outgoingHyps, &estimatedScores);
- pruneLatticeFB(connectedList, outgoingHyps, incomingEdges, estimatedScores, manager.GetBestHypothesis(), staticData.GetLatticeMBRPruningFactor(),staticData.GetMBRScale());
+ LMBR_Options const& lmbr = manager.options().lmbr;
+ MBR_Options const& mbr = manager.options().mbr;
+ pruneLatticeFB(connectedList, outgoingHyps, incomingEdges, estimatedScores,
+ manager.GetBestHypothesis(), lmbr.pruning_factor, mbr.scale);
calcNgramExpectations(connectedList, incomingEdges, ngramExpectations,false);
//expected length is sum of expected unigram counts