diff options
| author | pks <pks@users.noreply.github.com> | 2026-02-27 12:09:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-27 12:09:49 +0100 |
| commit | e7189f97ec29bd576fe79a260fa0e8cd25dcc968 (patch) | |
| tree | 227bc72ff0f7f72b8c6b3e6f735d922dd13da147 /src | |
| parent | c13b5650ac4bee7e674d263fcb778599bb449bff (diff) | |
| parent | 1377ffbdd2791e50cb3ca21d11c8c21febdbf911 (diff) | |
Claude
Diffstat (limited to 'src')
| -rw-r--r-- | src/hypergraph.cc | 11 | ||||
| -rw-r--r-- | src/hypergraph.hh | 6 | ||||
| -rw-r--r-- | src/odenwald.cc | 3 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/hypergraph.cc b/src/hypergraph.cc index 6ec8441..0c36abe 100644 --- a/src/hypergraph.cc +++ b/src/hypergraph.cc @@ -73,13 +73,13 @@ viterbi_path(Hypergraph& hg, Path& p) [](Node* n) { return n->incoming.size() == 0; }); //list<Node*>::iterator root = hg.nodes.begin(); + Hg::reset(hg.nodes, hg.edges); Hg::topological_sort(hg.nodes, root); - // ^^^ FIXME do I need to do this when reading from file? Semiring::Viterbi<score_t> semiring; Hg::init(hg.nodes, root, semiring); for (auto n: hg.nodes) { - Edge* best_edge; + Edge* best_edge = nullptr; bool best = false; for (auto e: n->incoming) { score_t s = semiring.one; @@ -135,10 +135,10 @@ derive(const Path& p, const Node* cur, vector<string>& carry) } } // FIXME this is probably not so good - unsigned j = 0; + unsigned j = 1; for (auto it: next->rule->target) { if (it->type() == G::NON_TERMINAL) { - derive(p, next->tails[next->rule->order[j]], carry); + derive(p, next->tails[next->rule->order[j]-1], carry); j++; } else { carry.push_back(it->symbol()); @@ -156,7 +156,8 @@ read(Hypergraph& hg, vector<G::Rule*>& rules, G::Vocabulary& vocab, const string msgpack::unpacker pac; while(true) { pac.reserve_buffer(32*1024); - size_t bytes = ifs.readsome(pac.buffer(), pac.buffer_capacity()); + ifs.read(pac.buffer(), pac.buffer_capacity()); + size_t bytes = ifs.gcount(); pac.buffer_consumed(bytes); msgpack::unpacked result; while(pac.next(&result)) { diff --git a/src/hypergraph.hh b/src/hypergraph.hh index 7a268c3..d782c9e 100644 --- a/src/hypergraph.hh +++ b/src/hypergraph.hh @@ -48,10 +48,10 @@ struct Node { string symbol; short left; short right; - score_t score; + score_t score = 0.0; vector<Edge*> incoming; vector<Edge*> outgoing; - unsigned int mark; + unsigned int mark = 0; inline bool is_marked() { return mark >= incoming.size(); }; friend ostream& operator<<(ostream& os, const Node& n); @@ -98,7 +98,7 @@ void write(Hypergraph& hg, vector<G::Rule*>& rules, const string& fn); // FIXME void -manual(Hypergraph& hg, vector<G::Rule*>& rules); +manual(Hypergraph& hg, vector<G::Rule*>& rules, G::Vocabulary& vocab); } // namespace diff --git a/src/odenwald.cc b/src/odenwald.cc index a520d0b..bdf21f8 100644 --- a/src/odenwald.cc +++ b/src/odenwald.cc @@ -20,8 +20,7 @@ main(int argc, char** argv) // viterbi clock_t begin_viterbi = clock(); Hg::Path p; - Hg::sv_path(hg, p); - exit(1); + Hg::viterbi_path(hg, p); vector<string> s; Hg::derive(p, p.back()->head, s); for (auto it: s) |
