diff options
author | Patrick Simianer <p@simianer.de> | 2015-11-16 17:22:39 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-11-16 17:22:39 +0100 |
commit | 6c43d8b7788e7c334d98fc937c2754fc946e3cc4 (patch) | |
tree | f48fd2275093e29a8e01c9afe00aff0871926f95 /src | |
parent | adf10dca9353bd9fa443eec67a30e2bbe58cbff4 (diff) |
sv_path
Diffstat (limited to 'src')
-rw-r--r-- | src/fast_weaver.cc | 3 | ||||
-rw-r--r-- | src/hypergraph.cc | 25 | ||||
-rw-r--r-- | src/hypergraph.hh | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/src/fast_weaver.cc b/src/fast_weaver.cc index bdf21f8..a520d0b 100644 --- a/src/fast_weaver.cc +++ b/src/fast_weaver.cc @@ -20,7 +20,8 @@ main(int argc, char** argv) // viterbi clock_t begin_viterbi = clock(); Hg::Path p; - Hg::viterbi_path(hg, p); + Hg::sv_path(hg, p); + exit(1); vector<string> s; Hg::derive(p, p.back()->head, s); for (auto it: s) 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) diff --git a/src/hypergraph.hh b/src/hypergraph.hh index d1217a5..7a268c3 100644 --- a/src/hypergraph.hh +++ b/src/hypergraph.hh @@ -84,6 +84,9 @@ void viterbi_path(Hypergraph& hg, Path& p); void +sv_path(Hypergraph& hg, Path& p); + +void derive(const Path& p, const Node* cur, vector<string>& carry); namespace io { |