#ifndef HYPERGRAPH_HH #define HYPERGRAPH_HH #include "grammar.hh" #include "semiring.hh" #include #include #include #include #include #include #include using namespace std; typedef double score_t; typedef double weight_t; namespace Hg { class Node; class Hyperedge { public: Node* head; vector tails; score_t score; vector f; unsigned int mark; //Grammar::Rule rule; FIXME unsigned int arity_; unsigned int arity(); bool is_marked(); string s(); }; class Node { public: unsigned int id; string symbol; unsigned int left; unsigned int right; score_t score; vector outgoing; vector incoming; string s(); }; class Hypergraph { public: vector nodes; vector edges; unsigned int arity_; map nodes_by_id; unsigned int arity(); void reset(); string s(); string json_s(); }; vector topological_sort(vector& nodes); void viterbi(vector& nodes, map nodes_by_id, Node* root); } // namespace #endif