From 6c43d8b7788e7c334d98fc937c2754fc946e3cc4 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 16 Nov 2015 17:22:39 +0100 Subject: sv_path --- src/hypergraph.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/hypergraph.cc') diff --git a/src/hypergraph.cc b/src/hypergraph.cc index 0a965d0..6ec8441 100644 --- a/src/hypergraph.cc +++ b/src/hypergraph.cc @@ -97,6 +97,31 @@ viterbi_path(Hypergraph& hg, Path& p) } } +void +sv_path(Hypergraph& hg, Path& p) +{ + list::iterator root = \ + find_if(hg.nodes.begin(), hg.nodes.end(), \ + [](Node* n) { return n->incoming.size() == 0; }); + //list::iterator root = hg.nodes.begin(); + + Hg::topological_sort(hg.nodes, root); + // ^^^ FIXME do I need to do this when reading from file? + + for (const auto it: hg.nodes) + it->score = 0; + (**root).score = 1.0; + + for (auto n: hg.nodes) { + Edge* best_edge; + bool best = false; + for (auto e: n->incoming) { + e->rule->f->repr(cout); + cout << endl; + } + } +} + void derive(const Path& p, const Node* cur, vector& carry) -- cgit v1.2.3