mosesdecoder/contrib/other-builds/moses2/SCFG/ActiveChart.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

2016-04-20 22:22:57 +03:00
#include <boost/foreach.hpp>
2016-05-01 11:32:49 +03:00
#include <boost/functional/hash_fwd.hpp>
#include "ActiveChart.h"
2016-04-20 18:54:08 +03:00
#include "InputPath.h"
2016-05-01 12:52:36 +03:00
#include "Word.h"
2016-04-20 18:54:08 +03:00
namespace Moses2
{
namespace SCFG
{
2016-05-01 12:52:36 +03:00
SymbolBindElement::SymbolBindElement(
const Range *range,
const SCFG::Word *word,
const Moses2::HypothesisColl *hypos)
:range(range)
,word(word)
,hypos(hypos)
{
assert( (word->isNonTerminal && hypos) || (!word->isNonTerminal && hypos == NULL));
}
2016-04-20 18:54:08 +03:00
2016-05-01 11:32:49 +03:00
size_t hash_value(const SymbolBindElement &obj)
{
size_t ret = (size_t) obj.range;
boost::hash_combine(ret, obj.word);
return ret;
}
////////////////////////////////////////////////////////////////////////////
2016-05-05 19:41:50 +03:00
void SymbolBind::Add(const Range &range, const SCFG::Word &word, const Moses2::HypothesisColl *hypos)
{
SymbolBindElement ele(&range, &word, hypos);
coll.push_back(ele);
if (word.isNonTerminal) {
++numNT;
}
}
2016-04-20 22:22:57 +03:00
std::ostream& operator<<(std::ostream &out, const SymbolBind &obj)
{
2016-05-01 11:32:49 +03:00
BOOST_FOREACH(const SymbolBindElement &ele, obj.coll) {
out << "("<< *ele.range << *ele.word << ") ";
2016-04-20 22:22:57 +03:00
}
return out;
}
2016-04-20 18:54:08 +03:00
}
}