summaryrefslogtreecommitdiff
path: root/src/hypergraph.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/hypergraph.cc')
-rw-r--r--src/hypergraph.cc25
1 files changed, 25 insertions, 0 deletions
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<Node*>::iterator root = \
+ find_if(hg.nodes.begin(), hg.nodes.end(), \
+ [](Node* n) { return n->incoming.size() == 0; });
+ //list<Node*>::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<string>& carry)