This commit is contained in:
Hieu Hoang 2016-03-20 12:48:47 +00:00
parent 4b81964572
commit 34acd73d23
3 changed files with 28 additions and 28 deletions

View File

@ -14,7 +14,7 @@ using namespace std;
namespace Moses2 {
std::ostream& operator<<(std::ostream &out, const TrellishNode &node)
std::ostream& operator<<(std::ostream &out, const TrellisNode &node)
{
out << "arcList=" << node.arcList->size() << " " << node.ind;
return out;
@ -30,7 +30,7 @@ TrellisPath::TrellisPath(const Hypothesis *hypo, const ArcLists &arcLists)
TrellisPath::TrellisPath(const TrellisPath &origPath,
size_t edgeIndex,
const TrellishNode &newNode,
const TrellisNode &newNode,
const ArcLists &arcLists,
MemPool &pool,
const System &system)
@ -53,7 +53,7 @@ TrellisPath::TrellisPath(const TrellisPath &origPath,
while (prevHypo != NULL) {
const ArcList *arcList = arcLists.GetArcList(prevHypo);
assert(arcList);
TrellishNode node(*arcList, 0);
TrellisNode node(*arcList, 0);
nodes.push_back(node);
prevHypo = prevHypo->GetPrevHypo();
@ -71,28 +71,11 @@ SCORE TrellisPath::GetFutureScore() const
return m_scores->GetTotalScore();
}
void TrellisPath::AddNodes(const Hypothesis *hypo, const ArcLists &arcLists)
{
if (hypo) {
// add this hypo
//cerr << "hypo=" << hypo << " " << flush;
//cerr << *hypo << endl;
const ArcList *list = arcLists.GetArcList(hypo);
assert(list);
TrellishNode node(*list, 0);
nodes.push_back(node);
// add prev hypos
const Hypothesis *prev = hypo->GetPrevHypo();
AddNodes(prev, arcLists);
}
}
void TrellisPath::OutputToStream(std::ostream &out, const System &system) const
{
//cerr << "path=" << this << " " << nodes.size() << endl;
for (int i = nodes.size() - 1; i >= 0; --i) {
const TrellishNode &node = nodes[i];
const TrellisNode &node = nodes[i];
const Hypothesis *hypo = static_cast<const Hypothesis*>((*node.arcList)[node.ind]);
//cerr << "hypo=" << hypo << " " << *hypo << endl;
hypo->GetTargetPhrase().OutputToStream(out);
@ -115,7 +98,7 @@ void TrellisPath::CreateDeviantPaths(TrellisPaths &paths,
//cerr << "prevEdgeChanged=" << prevEdgeChanged << endl;
for (size_t currEdge = prevEdgeChanged + 1 ; currEdge < sizePath ; currEdge++) {
TrellishNode newNode = nodes[currEdge];
TrellisNode newNode = nodes[currEdge];
assert(newNode.ind == 0);
const ArcList &arcList = *newNode.arcList;
@ -141,4 +124,21 @@ void TrellisPath::CalcScores(const Scores &origScores, MemPool &pool, const Syst
m_scores = scores;
}
void TrellisPath::AddNodes(const Hypothesis *hypo, const ArcLists &arcLists)
{
if (hypo) {
// add this hypo
//cerr << "hypo=" << hypo << " " << flush;
//cerr << *hypo << endl;
const ArcList *list = arcLists.GetArcList(hypo);
assert(list);
TrellisNode node(*list, 0);
nodes.push_back(node);
// add prev hypos
const Hypothesis *prev = hypo->GetPrevHypo();
AddNodes(prev, arcLists);
}
}
} /* namespace Moses2 */

View File

@ -17,15 +17,15 @@ class Hypothesis;
class System;
class TrellisPaths;
class TrellishNode
class TrellisNode
{
friend std::ostream& operator<<(std::ostream &, const TrellishNode &);
friend std::ostream& operator<<(std::ostream &, const TrellisNode &);
public:
const ArcList *arcList;
size_t ind;
TrellishNode(const ArcList &varcList, size_t vind)
TrellisNode(const ArcList &varcList, size_t vind)
:arcList(&varcList)
,ind(vind)
{}
@ -33,7 +33,7 @@ public:
class TrellisPath {
public:
std::vector<TrellishNode> nodes;
std::vector<TrellisNode> nodes;
int prevEdgeChanged;
/**< the last node that was wiggled to create this path
@ -46,7 +46,7 @@ public:
*/
TrellisPath(const TrellisPath &origPath,
size_t edgeIndex,
const TrellishNode &newNode,
const TrellisNode &newNode,
const ArcLists &arcLists,
MemPool &pool,
const System &system);

View File

@ -14,7 +14,7 @@ namespace Moses2 {
struct CompareTrellisPathCollection {
bool operator()(const TrellisPath* pathA, const TrellisPath* pathB) const {
return (pathA->GetFutureScore() > pathB->GetFutureScore());
return (pathA->GetFutureScore() < pathB->GetFutureScore());
}
};