From 567f2bd17c05d31cd8a9b9d351f9030cddf53cb7 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Wed, 9 Jul 2014 15:26:00 +0200 Subject: c++ implementation --- fast/hypergraph.hh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 fast/hypergraph.hh (limited to 'fast/hypergraph.hh') diff --git a/fast/hypergraph.hh b/fast/hypergraph.hh new file mode 100644 index 0000000..6e53045 --- /dev/null +++ b/fast/hypergraph.hh @@ -0,0 +1,76 @@ +#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 + -- cgit v1.2.3