more debug functions

This commit is contained in:
Hieu Hoang 2013-12-11 20:03:30 +00:00
parent fb356606e9
commit bc9ce334d0
5 changed files with 35 additions and 0 deletions

View File

@ -36,6 +36,7 @@ using namespace std;
namespace Moses
{
extern bool g_mosesDebug;
ChartCellBase::ChartCellBase(size_t startPos, size_t endPos) :
m_coverage(startPos, endPos),
@ -94,6 +95,10 @@ void ChartCell::ProcessSentence(const ChartTranslationOptionList &transOptList
for (size_t i = 0; i < transOptList.GetSize(); ++i) {
const ChartTranslationOptions &transOpt = transOptList.Get(i);
RuleCube *ruleCube = new RuleCube(transOpt, allChartCells, m_manager);
if (g_mosesDebug) {
cerr << *ruleCube << endl;
}
queue.Add(ruleCube);
}

View File

@ -90,10 +90,20 @@ void ChartManager::ProcessSentence()
const InputPath &inputPath = m_parser.GetInputPath(range);
m_translationOptionList.Evaluate(m_source, inputPath);
g_mosesDebug = false;
if (startPos == 1 && endPos == 1) {
cerr << m_translationOptionList << endl;
g_mosesDebug = true;
}
// decode
ChartCell &cell = m_hypoStackColl.Get(range);
cell.ProcessSentence(m_translationOptionList, m_hypoStackColl);
if (g_mosesDebug) {
cerr << cell << endl;
}
m_translationOptionList.Clear();
cell.PruneToSize();
cell.CleanupArcList();

View File

@ -59,6 +59,9 @@ public:
static float CalcEstimateOfBestScore(const TargetPhraseCollection &,
const StackVec &);
size_t GetSize() const
{ return m_collection.size(); }
//! @todo dunno
const StackVec &GetStackVec() const {
return m_stackVec;

View File

@ -30,8 +30,11 @@
#include <boost/functional/hash.hpp>
using namespace std;
namespace Moses
{
extern bool g_mosesDebug;
// initialise the RuleCube by creating the top-left corner item
RuleCube::RuleCube(const ChartTranslationOptions &transOpt,
@ -39,6 +42,10 @@ RuleCube::RuleCube(const ChartTranslationOptions &transOpt,
ChartManager &manager)
: m_transOpt(transOpt)
{
if (g_mosesDebug) {
cerr << transOpt.GetSize() << endl;
}
RuleCubeItem *item = new RuleCubeItem(transOpt, allChartCells);
m_covered.insert(item);
if (StaticData::Instance().GetCubePruningLazyScoring()) {
@ -98,4 +105,9 @@ void RuleCube::CreateNeighbor(const RuleCubeItem &item, int dimensionIndex,
}
}
std::ostream& operator<<(std::ostream &out, const RuleCube &obj)
{
out << obj.GetItemSetSize();
return out;
}
}

View File

@ -90,6 +90,8 @@ public:
*/
class RuleCube
{
friend std::ostream& operator<<(std::ostream &out, const RuleCube &obj);
public:
RuleCube(const ChartTranslationOptions &, const ChartCellCollection &,
ChartManager &);
@ -112,6 +114,9 @@ public:
return m_transOpt;
}
size_t GetItemSetSize() const
{ return m_covered.size(); }
private:
#if defined(BOOST_VERSION) && (BOOST_VERSION >= 104200)
typedef boost::unordered_set<RuleCubeItem*,