summaryrefslogtreecommitdiff
path: root/src/hypergraph.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-11-16 17:22:39 +0100
committerPatrick Simianer <p@simianer.de>2015-11-16 17:22:39 +0100
commit6c43d8b7788e7c334d98fc937c2754fc946e3cc4 (patch)
treef48fd2275093e29a8e01c9afe00aff0871926f95 /src/hypergraph.cc
parentadf10dca9353bd9fa443eec67a30e2bbe58cbff4 (diff)
sv_path
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)