mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 19:37:58 +03:00
debug
This commit is contained in:
parent
19b8bc50b7
commit
fb2bbf99fc
@ -18,6 +18,7 @@
|
||||
***********************************************************************/
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include "AlignmentInfo.h"
|
||||
#include "legacy/Util2.h"
|
||||
#include "util/exception.hh"
|
||||
@ -156,13 +157,15 @@ std::vector<size_t> AlignmentInfo::GetSourceIndex2PosMap() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream &AlignmentInfo::Debug(std::ostream &out, const System &system) const
|
||||
std::string AlignmentInfo::Debug(const System &system) const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
AlignmentInfo::const_iterator iter;
|
||||
for (iter = begin(); iter != end(); ++iter) {
|
||||
out << iter->first << "-" << iter->second << " ";
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
m_nonTermIndexMap == rhs.m_nonTermIndexMap;
|
||||
}
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
private:
|
||||
//! AlignmentInfo objects should only be created by an AlignmentInfoCollection
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
virtual SCORE GetFutureScore() const = 0;
|
||||
virtual void EvaluateWhenApplied() = 0;
|
||||
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const = 0;
|
||||
virtual std::string Debug(const System &system) const = 0;
|
||||
|
||||
protected:
|
||||
ManagerBase *m_mgr;
|
||||
|
@ -5,12 +5,15 @@
|
||||
* Author: hieu
|
||||
*/
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "HypothesisColl.h"
|
||||
#include "ManagerBase.h"
|
||||
#include "System.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
@ -124,14 +127,15 @@ void HypothesisColl::Clear()
|
||||
m_coll.clear();
|
||||
}
|
||||
|
||||
std::ostream &HypothesisColl::Debug(std::ostream &out, const System &system) const
|
||||
std::string HypothesisColl::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
BOOST_FOREACH (const HypothesisBase *hypo, m_coll) {
|
||||
hypo->Debug(out, system);
|
||||
out << hypo->Debug(system);
|
||||
out << std::endl << std::endl;
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
} /* namespace Moses2 */
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
const ManagerBase &mgr,
|
||||
ArcLists &arcLists) const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
_HCType m_coll;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include "Word.h"
|
||||
#include "MemPool.h"
|
||||
@ -94,19 +95,19 @@ public:
|
||||
|
||||
virtual SubPhrase<WORD> GetSubPhrase(size_t start, size_t size) const = 0;
|
||||
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const
|
||||
virtual std::string Debug(const System &system) const
|
||||
{
|
||||
std::stringstream out;
|
||||
size_t size = GetSize();
|
||||
if (size) {
|
||||
(*this)[0].Debug(out, system);
|
||||
out << (*this)[0].Debug(system);
|
||||
for (size_t i = 1; i < size; ++i) {
|
||||
const WORD &word = (*this)[i];
|
||||
out << " ";
|
||||
word.Debug(out, system);
|
||||
out << " " << word.Debug(system);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
virtual void OutputToStream(std::ostream &out) const
|
||||
|
@ -39,8 +39,9 @@ void Stacks::Init(const Manager &mgr, size_t numStacks)
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &Stacks::Debug(std::ostream &out, const System &system) const
|
||||
std::string Stacks::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
for (size_t i = 0; i < GetSize(); ++i) {
|
||||
const Stack *stack = m_stacks[i];
|
||||
if (stack) {
|
||||
@ -50,7 +51,7 @@ std::ostream &Stacks::Debug(std::ostream &out, const System &system) const
|
||||
out << "N ";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Stacks::Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
|
||||
ArcLists &arcLists);
|
||||
|
||||
std::ostream & Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
const Manager &m_mgr;
|
||||
|
@ -91,10 +91,11 @@ CubeEdge::CubeEdge(Manager &mgr, const Hypotheses &hypos, const InputPath &path,
|
||||
estimatedScore = mgr.GetEstimatedScores().CalcEstimatedScore(newBitmap);
|
||||
}
|
||||
|
||||
std::ostream &CubeEdge::Debug(std::ostream &out, const System &system) const
|
||||
std::string CubeEdge::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << newBitmap;
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
bool CubeEdge::SetSeenPosition(const size_t x, const size_t y,
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
SeenPositions &seenPositions,
|
||||
std::deque<QueueItem*, MemPoolAllocator<QueueItem*> > &queueItemRecycler);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -107,8 +107,10 @@ bool Hypothesis::operator==(const Hypothesis &other) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const
|
||||
std::string Hypothesis::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
|
||||
// coverage
|
||||
out << GetBitmap() << " " << GetInputPath().range << " ";
|
||||
|
||||
@ -122,12 +124,12 @@ std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const
|
||||
}
|
||||
|
||||
// string
|
||||
Debug(out, m_mgr->system);
|
||||
//Debug(out, m_mgr->system);
|
||||
out << " ";
|
||||
out << "fc=" << GetFutureScore() << " ";
|
||||
GetScores().Debug(out, GetManager().system);
|
||||
out << GetScores().Debug(GetManager().system);
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Hypothesis::OutputToStream(std::ostream &out) const
|
||||
@ -156,7 +158,7 @@ void Hypothesis::OutputToStream(std::ostream &out) const
|
||||
out << m_path->range.GetStartPos() << "-" << m_path->range.GetEndPos() << ",";
|
||||
|
||||
// score breakdown
|
||||
m_scores->Debug(out, m_mgr->system);
|
||||
out << m_scores->Debug(m_mgr->system);
|
||||
|
||||
out << "| ";
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
return *m_targetPhrase;
|
||||
}
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
virtual void OutputToStream(std::ostream &out) const;
|
||||
|
||||
|
@ -4,11 +4,14 @@
|
||||
* Created on: 23 Oct 2015
|
||||
* Author: hieu
|
||||
*/
|
||||
#include <sstream>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "InputPath.h"
|
||||
#include "TargetPhrases.h"
|
||||
#include "../TranslationModel/PhraseTable.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
InputPath::InputPath(MemPool &pool, const SubPhrase<Moses2::Word> &subPhrase,
|
||||
@ -42,11 +45,13 @@ const TargetPhrases *InputPath::GetTargetPhrases(const PhraseTable &pt) const
|
||||
return targetPhrases[ptInd];
|
||||
}
|
||||
|
||||
std::ostream &InputPath::Debug(std::ostream &out, const System &system) const
|
||||
std::string InputPath::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
|
||||
out << range << " ";
|
||||
subPhrase.Debug(out, system);
|
||||
return out;
|
||||
out << subPhrase.Debug(system);
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
return m_isUsed;
|
||||
}
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
bool m_isUsed;
|
||||
|
@ -232,7 +232,7 @@ std::string Manager::OutputNBest()
|
||||
|
||||
if (ok) {
|
||||
out << transId << " |||";
|
||||
path->Debug(out, system);
|
||||
out << path->Debug(system);
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,9 @@ void Stacks::Init(const Manager &mgr, size_t numStacks)
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &Stacks::Debug(std::ostream &out, const System &system) const
|
||||
std::string Stacks::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
for (size_t i = 0; i < GetSize(); ++i) {
|
||||
const Stack *stack = m_stacks[i];
|
||||
if (stack) {
|
||||
@ -50,7 +51,7 @@ std::ostream &Stacks::Debug(std::ostream &out, const System &system) const
|
||||
out << "N ";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Stacks::Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
|
||||
ArcLists &arcLists);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
const Manager &m_mgr;
|
||||
|
@ -15,10 +15,11 @@ using namespace std;
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
std::ostream &Sentence::XMLOption::Debug(std::ostream &out, const System &system) const
|
||||
std::string Sentence::XMLOption::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << "[" << startPos << "," << phraseSize << "]=" << nodeName;
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
std::string nodeName;
|
||||
size_t startPos, phraseSize;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include "TargetPhraseImpl.h"
|
||||
#include "../Scores.h"
|
||||
@ -48,12 +49,12 @@ TargetPhraseImpl::~TargetPhraseImpl()
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
std::ostream &TargetPhraseImpl::Debug(std::ostream &out, const System &system) const
|
||||
std::string TargetPhraseImpl::Debug(const System &system) const
|
||||
{
|
||||
Phrase<Moses2::Word>::Debug(out, system);
|
||||
out << " SCORES:";
|
||||
GetScores().Debug(out, system);
|
||||
return out;
|
||||
stringstream out;
|
||||
out << Phrase<Moses2::Word>::Debug(system);
|
||||
out << " SCORES:" << GetScores().Debug(system);
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
virtual ~TargetPhraseImpl();
|
||||
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
virtual std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@ -38,13 +38,14 @@ TargetPhrases::~TargetPhrases()
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
std::ostream &TargetPhrases::Debug(std::ostream &out, const System &system) const
|
||||
std::string TargetPhrases::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
BOOST_FOREACH(const TargetPhrase<Moses2::Word> *tp, *this){
|
||||
tp->Debug(out, system);
|
||||
out << tp->Debug(system);
|
||||
out << endl;
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void TargetPhrases::SortAndPrune(size_t tableLimit)
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
void SortAndPrune(size_t tableLimit);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
Coll m_coll;
|
||||
|
@ -16,10 +16,11 @@ using namespace std;
|
||||
namespace Moses2
|
||||
{
|
||||
|
||||
std::ostream &TrellisNode::Debug(std::ostream &out, const System &system) const
|
||||
std::string TrellisNode::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << "arcList=" << arcList->size() << " " << ind;
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -75,17 +76,18 @@ SCORE TrellisPath::GetFutureScore() const
|
||||
return m_scores->GetTotalScore();
|
||||
}
|
||||
|
||||
std::ostream &TrellisPath::Debug(std::ostream &out, const System &system) const
|
||||
std::string TrellisPath::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << ToString();
|
||||
out << "||| ";
|
||||
|
||||
GetScores().Debug(out, system);
|
||||
out << GetScores().Debug(system);
|
||||
out << "||| ";
|
||||
|
||||
out << GetScores().GetTotalScore();
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
std::string TrellisPath::ToString() const
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
return (*arcList)[ind];
|
||||
}
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
};
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
}
|
||||
SCORE GetFutureScore() const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
std::string ToString() const;
|
||||
|
||||
//! create a set of next best paths by wiggling 1 of the node at a time.
|
||||
|
@ -57,14 +57,15 @@ std::vector<const SymbolBindElement*> SymbolBind::GetNTElements() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream &SymbolBind::Debug(std::ostream &out, const System &system) const
|
||||
std::string SymbolBind::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
BOOST_FOREACH(const SymbolBindElement &ele, coll) {
|
||||
out << "("<< *ele.range;
|
||||
ele.word->Debug(out, system);
|
||||
out << ele.word->Debug(system);
|
||||
out << ") ";
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
bool operator==(const SymbolBind &compare) const
|
||||
{ return coll == compare.coll; }
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
};
|
||||
|
||||
|
@ -29,15 +29,16 @@ SeenPosition::SeenPosition(MemPool &pool, const SCFG::TargetPhrases *vtps, size_
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &SeenPosition::Debug(std::ostream &out, const System &system) const
|
||||
std::string SeenPosition::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << tps << " " << tpInd << " ";
|
||||
|
||||
for (size_t i = 0; i < hypoIndColl.size(); ++i) {
|
||||
out << hypoIndColl[i] << " ";
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
bool SeenPosition::operator==(const SeenPosition &compare) const
|
||||
@ -178,14 +179,15 @@ void QueueItem::CreateNext(
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &QueueItem::Debug(std::ostream &out, const System &system) const
|
||||
std::string QueueItem::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << hypo << " " << &(*tps)[tpInd] << "(" << tps << " " << tpInd << ") ";
|
||||
for (size_t i = 0; i < hypoIndColl.size(); ++i) {
|
||||
out << hypoIndColl[i] << " ";
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public:
|
||||
bool operator==(const SeenPosition &compare) const;
|
||||
size_t hash() const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
};
|
||||
|
||||
@ -86,7 +86,7 @@ public:
|
||||
SeenPositions &seenPositions,
|
||||
const SCFG::InputPath &path);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
typedef Vector<const Moses2::HypothesisColl *> HyposColl;
|
||||
|
@ -131,16 +131,16 @@ void Hypothesis::OutputToStream(std::ostream &out) const
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const
|
||||
std::string Hypothesis::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << this;
|
||||
|
||||
out << " RANGE:";
|
||||
out << m_path->range;
|
||||
|
||||
// score
|
||||
out << " SCORE:";
|
||||
GetScores().Debug(out, GetManager().system);
|
||||
out << " SCORE:" << GetScores().Debug(GetManager().system);
|
||||
|
||||
/*
|
||||
out << " m_prevHypos=" << m_prevHypos.size() << " ";
|
||||
@ -149,16 +149,16 @@ std::ostream &Hypothesis::Debug(std::ostream &out, const System &system) const
|
||||
}
|
||||
*/
|
||||
|
||||
m_targetPhrase->Debug(out, GetManager().system);
|
||||
out << m_targetPhrase->Debug(GetManager().system);
|
||||
|
||||
// recursive
|
||||
for (size_t i = 0; i < m_prevHypos.size(); ++i) {
|
||||
const Hypothesis &prevHypo = *m_prevHypos[i];
|
||||
out << endl;
|
||||
prevHypo.Debug(out, system);
|
||||
out << prevHypo.Debug(system);
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
} // namespaces
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
void OutputToStream(std::ostream &out) const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
const SCFG::TargetPhraseImpl *m_targetPhrase;
|
||||
|
@ -37,10 +37,11 @@ InputPath::~InputPath()
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
std::ostream &InputPath::Debug(std::ostream &out, const System &system) const
|
||||
std::string InputPath::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << range << " ";
|
||||
subPhrase.Debug(out, system);
|
||||
out << subPhrase.Debug(system);
|
||||
out << " " << prefixPath << " ";
|
||||
|
||||
const Vector<ActiveChartEntry*> &activeEntries = *GetActiveChart(1).entries;
|
||||
@ -48,7 +49,7 @@ std::ostream &InputPath::Debug(std::ostream &out, const System &system) const
|
||||
|
||||
for (size_t i = 0; i < activeEntries.size(); ++i) {
|
||||
const ActiveChartEntry &entry = *activeEntries[i];
|
||||
entry.GetSymbolBind().Debug(out, system);
|
||||
out << entry.GetSymbolBind().Debug(system);
|
||||
out << "| ";
|
||||
}
|
||||
|
||||
@ -59,12 +60,12 @@ std::ostream &InputPath::Debug(std::ostream &out, const System &system) const
|
||||
BOOST_FOREACH(const SCFG::InputPath::Coll::value_type &valPair, *targetPhrases) {
|
||||
const SymbolBind &symbolBind = valPair.first;
|
||||
const SCFG::TargetPhrases &tps = *valPair.second;
|
||||
symbolBind.Debug(out, system);
|
||||
out << symbolBind.Debug(system);
|
||||
//out << "=" << tps.GetSize() << " ";
|
||||
tps.Debug(out, system);
|
||||
out << tps.Debug(system);
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void InputPath::AddTargetPhrase(
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
size_t GetNumRules() const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
ActiveChart *m_activeChart;
|
||||
|
@ -67,19 +67,20 @@ void InputPaths::Init(const InputType &input, const ManagerBase &mgr)
|
||||
|
||||
}
|
||||
|
||||
std::ostream &InputPaths::Debug(std::ostream &out, const System &system) const
|
||||
std::string InputPaths::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
const Matrix<InputPath*> &matrix = GetMatrix();
|
||||
for (size_t i = 0; i < matrix.GetRows(); ++i) {
|
||||
for (size_t j = 0; j < matrix.GetCols(); ++j) {
|
||||
SCFG::InputPath *path = matrix.GetValue(i, j);
|
||||
if (path) {
|
||||
path->Debug(out, system);
|
||||
out << path->Debug(system);
|
||||
out << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
return *m_matrix;
|
||||
}
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
Matrix<InputPath*> *m_matrix;
|
||||
|
@ -62,9 +62,9 @@ void Manager::Decode()
|
||||
cerr << endl << "startPos=" << startPos << endl;
|
||||
SCFG::InputPath &initPath = *m_inputPaths.GetMatrix().GetValue(startPos, 0);
|
||||
|
||||
//cerr << "BEFORE path=" << m_inputPaths << endl;
|
||||
cerr << "BEFORE InitActiveChart=" << initPath.Debug(system) << endl;
|
||||
InitActiveChart(initPath);
|
||||
cerr << "AFTER path=" << endl;
|
||||
cerr << "AFTER InitActiveChart=" << initPath.Debug(system) << endl;
|
||||
|
||||
int maxPhraseSize = inputSize - startPos + 1;
|
||||
for (int phraseSize = 1; phraseSize < maxPhraseSize; ++phraseSize) {
|
||||
@ -73,14 +73,14 @@ void Manager::Decode()
|
||||
|
||||
Stack &stack = m_stacks.GetStack(startPos, phraseSize);
|
||||
|
||||
cerr << "BEFORE LOOKUP path=" << endl;
|
||||
cerr << "BEFORE LOOKUP path=" << path.Debug(system) << endl;
|
||||
Lookup(path);
|
||||
cerr << "AFTER LOOKUP path=" << endl;
|
||||
cerr << "AFTER LOOKUP path=" << path.Debug(system) << endl;
|
||||
Decode(path, stack);
|
||||
cerr << "AFTER DECODE path=" << endl;
|
||||
cerr << "AFTER DECODE path=" << path.Debug(system) << endl;
|
||||
|
||||
LookupUnary(path);
|
||||
//cerr << "AFTER LookupUnary path=" << path << endl;
|
||||
cerr << "AFTER LookupUnary path=" << path.Debug(system) << endl;
|
||||
|
||||
//cerr << "#rules=" << path.GetNumRules() << endl;
|
||||
}
|
||||
@ -317,7 +317,7 @@ std::string Manager::OutputBest() const
|
||||
|
||||
bestHypo->OutputToStream(out);
|
||||
cerr << "BEST TRANSLATION: ";
|
||||
bestHypo->Debug(cerr, system);
|
||||
cerr << bestHypo->Debug(system);
|
||||
cerr << " " << out.str() << endl;
|
||||
}
|
||||
else {
|
||||
|
@ -104,19 +104,19 @@ const Hypothesis *Stack::GetBestHypo(
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::ostream &Stack::Debug(std::ostream &out, const System &system) const
|
||||
std::string Stack::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
BOOST_FOREACH (const SCFG::Stack::Coll::value_type &valPair, m_coll) {
|
||||
const SCFG::Word &lhs = valPair.first;
|
||||
const Moses2::HypothesisColl &hypos = *valPair.second;
|
||||
out << "lhs=";
|
||||
lhs.Debug(out, system);
|
||||
out << "lhs=" << lhs.Debug(system);
|
||||
out << "=" << hypos.GetSize() << endl;
|
||||
hypos.Debug(out, system);
|
||||
out << hypos.Debug(system);
|
||||
out << endl;
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
const Manager &mgr,
|
||||
ArcLists &arcLists) const;
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
const Manager &m_mgr;
|
||||
|
@ -63,24 +63,23 @@ TargetPhraseImpl::~TargetPhraseImpl()
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
std::ostream &TargetPhraseImpl::Debug(std::ostream &out, const System &system) const
|
||||
std::string TargetPhraseImpl::Debug(const System &system) const
|
||||
{
|
||||
lhs.Debug(out, system);
|
||||
stringstream out;
|
||||
out << lhs.Debug(system);
|
||||
out << " -> ";
|
||||
for (size_t i = 0; i < GetSize(); ++i) {
|
||||
const SCFG::Word &word = (*this)[i];
|
||||
word.Debug(out, system);
|
||||
out << " ";
|
||||
out << word.Debug(system) << " ";
|
||||
}
|
||||
out << "pt=" << pt.GetName();
|
||||
out << " SCORES:";
|
||||
GetScores().Debug(out, system);
|
||||
out << " SCORES:" << GetScores().Debug(system);
|
||||
out << " ALIGN:";
|
||||
GetAlignTerm().Debug(out, system);
|
||||
out << GetAlignTerm().Debug(system);
|
||||
out << " ";
|
||||
GetAlignNonTerm().Debug(out, system);
|
||||
out << GetAlignNonTerm().Debug(system);
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void TargetPhraseImpl::SetAlignmentInfo(const std::string &alignString)
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
|
||||
void SetAlignmentInfo(const std::string &alignString);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
//mutable void *chartState;
|
||||
protected:
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include "TargetPhrases.h"
|
||||
#include "TargetPhraseImpl.h"
|
||||
@ -49,13 +50,15 @@ void TargetPhrases::SortAndPrune(size_t tableLimit)
|
||||
//cerr << "TargetPhrases=" << GetSize() << endl;
|
||||
}
|
||||
|
||||
std::ostream &TargetPhrases::Debug(std::ostream &out, const System &system) const
|
||||
std::string TargetPhrases::Debug(const System &system) const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
BOOST_FOREACH(const SCFG::TargetPhraseImpl *tp, m_coll) {
|
||||
out << std::endl;
|
||||
tp->Debug(out, system);
|
||||
out << tp->Debug(system);
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
void SortAndPrune(size_t tableLimit);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
Coll m_coll;
|
||||
|
@ -75,16 +75,17 @@ void Word::OutputToStream(std::ostream &out) const
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream &Word::Debug(std::ostream &out, const System &system) const
|
||||
std::string Word::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
if (isNonTerminal) {
|
||||
out << "[";
|
||||
}
|
||||
Moses2::Word::Debug(out, system);
|
||||
out << Moses2::Word::Debug(system);
|
||||
if (isNonTerminal) {
|
||||
out << "]";
|
||||
}
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
size_t hash() const;
|
||||
|
||||
virtual void OutputToStream(std::ostream &out) const;
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
virtual std::string Debug(const System &system) const;
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@ -243,8 +243,9 @@ void Scores::CreateFromString(const std::string &str,
|
||||
PlusEquals(system, featureFunction, scores);
|
||||
}
|
||||
|
||||
std::ostream &Scores::Debug(std::ostream &out, const System &system) const
|
||||
std::string Scores::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
out << "total=" << m_total;
|
||||
|
||||
if (system.options.nbest.nbest_size) {
|
||||
@ -257,7 +258,7 @@ std::ostream &Scores::Debug(std::ostream &out, const System &system) const
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
// static functions to work out estimated scores
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
void Assign(const System &system, const FeatureFunction &featureFunction,
|
||||
const std::vector<SCORE> &scores);
|
||||
|
||||
std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
std::string Debug(const System &system) const;
|
||||
|
||||
// static functions to work out estimated scores
|
||||
static SCORE CalcWeightedScore(const System &system,
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
#include "Phrase.h"
|
||||
#include "Word.h"
|
||||
#include "SCFG/Word.h"
|
||||
@ -29,18 +30,18 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const
|
||||
virtual std::string Debug(const System &system) const
|
||||
{
|
||||
std::stringstream out;
|
||||
if (GetSize()) {
|
||||
(*this)[0].Debug(out, system);
|
||||
out << (*this)[0].Debug(system);
|
||||
for (size_t i = 1; i < GetSize(); ++i) {
|
||||
const WORD &word = (*this)[i];
|
||||
out << " ";
|
||||
word.Debug(out, system);
|
||||
out << " " << word.Debug(system);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
#include "PhraseImplTemplate.h"
|
||||
#include "System.h"
|
||||
#include "Scores.h"
|
||||
@ -45,13 +46,13 @@ public:
|
||||
SCORE *GetScoresProperty(int propertyInd) const
|
||||
{ return scoreProperties ? scoreProperties + propertyInd : NULL; }
|
||||
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const
|
||||
virtual std::string Debug(const System &system) const
|
||||
{
|
||||
Phrase<WORD>::Debug(out, system);
|
||||
out << " SCORES:";
|
||||
GetScores().Debug(out, system);
|
||||
std::stringstream out;
|
||||
out << Phrase<WORD>::Debug(system);
|
||||
out << " SCORES:" << GetScores().Debug(system);
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -405,7 +405,7 @@ void ProbingPT::InitActiveChart(
|
||||
const SCFG::Manager &mgr,
|
||||
SCFG::InputPath &path) const
|
||||
{
|
||||
cerr << "InitActiveChart=" << path.Debug(cerr, mgr.system) << endl;
|
||||
//cerr << "InitActiveChart=" << path.Debug(cerr, mgr.system) << endl;
|
||||
size_t ptInd = GetPtInd();
|
||||
ActiveChartEntryProbing *chartEntry = new (pool.Allocate<ActiveChartEntryProbing>()) ActiveChartEntryProbing(pool);
|
||||
path.AddActiveChartEntry(ptInd, chartEntry);
|
||||
@ -417,7 +417,7 @@ void ProbingPT::Lookup(MemPool &pool,
|
||||
const SCFG::Stacks &stacks,
|
||||
SCFG::InputPath &path) const
|
||||
{
|
||||
cerr << "Lookup=" << endl;
|
||||
//cerr << "Lookup=" << endl;
|
||||
if (path.range.GetNumWordsCovered() > maxChartSpan) {
|
||||
return;
|
||||
}
|
||||
@ -521,9 +521,12 @@ void ProbingPT::LookupGivenNode(
|
||||
SCFG::InputPath &outPath) const
|
||||
{
|
||||
std::pair<bool, uint64_t> key = prevEntry.GetKey(wordSought, *this);
|
||||
//cerr << "wordSought=" << wordSought.Debug(cerr, mgr.system) << " " << key.first << endl;
|
||||
cerr << "wordSought=" << wordSought.Debug(mgr.system) << endl;
|
||||
//cerr << "HELLO" << endl;
|
||||
|
||||
if (!key.first) {
|
||||
// should only happen when looking up unary rules
|
||||
// should only occasionally happen when looking up unary rules
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,9 @@ bool Word::operator<(const Word &compare) const
|
||||
return (cmp < 0);
|
||||
}
|
||||
|
||||
std::ostream &Word::Debug(std::ostream &out, const System &system) const
|
||||
std::string Word::Debug(const System &system) const
|
||||
{
|
||||
stringstream out;
|
||||
bool outputAlready = false;
|
||||
for (size_t i = 0; i < MAX_NUM_FACTORS; ++i) {
|
||||
const Factor *factor = m_factors[i];
|
||||
@ -85,7 +86,7 @@ std::ostream &Word::Debug(std::ostream &out, const System &system) const
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
return out.str();
|
||||
}
|
||||
|
||||
void Word::OutputToStream(std::ostream &out) const
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void OutputToStream(std::ostream &out) const;
|
||||
virtual std::ostream &Debug(std::ostream &out, const System &system) const;
|
||||
virtual std::string Debug(const System &system) const;
|
||||
|
||||
std::string GetString(const FactorList &factorTypes) const;
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user