From a8a5b43f2dc32bd1b45006fd43989dc71e74ba0e Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 31 Jan 2017 22:21:59 +0000 Subject: move moses2 to root --- moses2/SCFG/ActiveChart.cpp | 109 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 moses2/SCFG/ActiveChart.cpp (limited to 'moses2/SCFG/ActiveChart.cpp') diff --git a/moses2/SCFG/ActiveChart.cpp b/moses2/SCFG/ActiveChart.cpp new file mode 100644 index 000000000..711767b2f --- /dev/null +++ b/moses2/SCFG/ActiveChart.cpp @@ -0,0 +1,109 @@ +#include +#include +#include "ActiveChart.h" +#include "InputPath.h" +#include "Word.h" +#include "Hypothesis.h" +#include "../Vector.h" + +using namespace std; + +namespace Moses2 +{ +namespace SCFG +{ +SymbolBindElement::SymbolBindElement() +{ +} + +SymbolBindElement::SymbolBindElement( + const Moses2::Range &range, + const SCFG::Word &word, + const Moses2::Hypotheses *hypos) +:m_range(&range) +,word(&word) +,hypos(hypos) +{ + assert( (word.isNonTerminal && hypos) || (!word.isNonTerminal && hypos == NULL)); +} + +size_t hash_value(const SymbolBindElement &obj) +{ + size_t ret = (size_t) obj.hypos; + boost::hash_combine(ret, obj.word); + + return ret; +} + +std::string SymbolBindElement::Debug(const System &system) const +{ + stringstream out; + out << "("; + out << *m_range; + out << word->Debug(system); + out << ")"; + + return out.str(); +} + +//////////////////////////////////////////////////////////////////////////// +SymbolBind::SymbolBind(MemPool &pool) +:coll(pool) +,numNT(0) +{ +} + +void SymbolBind::Add(const Range &range, const SCFG::Word &word, const Moses2::Hypotheses *hypos) +{ + SymbolBindElement ele(range, word, hypos); + coll.push_back(ele); + + if (word.isNonTerminal) { + ++numNT; + } +} + +std::vector SymbolBind::GetNTElements() const +{ + std::vector ret; + + for (size_t i = 0; i < coll.size(); ++i) { + const SymbolBindElement &ele = coll[i]; + //cerr << "ele=" << ele.word->isNonTerminal << " " << ele.hypos << endl; + + if (ele.word->isNonTerminal) { + ret.push_back(&ele); + } + } + + return ret; +} + +std::string SymbolBind::Debug(const System &system) const +{ + stringstream out; + BOOST_FOREACH(const SymbolBindElement &ele, coll) { + out << ele.Debug(system) << " "; + } + return out.str(); +} +//////////////////////////////////////////////////////////////////////////// +ActiveChartEntry::ActiveChartEntry(MemPool &pool) +:m_symbolBind(pool) +{ +} + +//////////////////////////////////////////////////////////////////////////// +ActiveChart::ActiveChart(MemPool &pool) +:entries(pool) +{ +} + +ActiveChart::~ActiveChart() +{ + +} + +} +} + -- cgit v1.2.3