From 625269764ebbe8d0b566e6ef5fc26a6bccd4181d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 13 Jul 2014 14:04:45 +0200 Subject: init --- test_msgpack.cc | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 test_msgpack.cc (limited to 'test_msgpack.cc') diff --git a/test_msgpack.cc b/test_msgpack.cc new file mode 100644 index 0000000..1204b05 --- /dev/null +++ b/test_msgpack.cc @@ -0,0 +1,83 @@ +#include +#include +#include + +/* + * http://msgpack.org/ + * + */ +#include +#include +#include + +using namespace std; + + +struct Node { + int id; + string cat; + vector span; + + MSGPACK_DEFINE(id, cat, span); +}; + +struct Vector { + double CountEF; + double EgivenFCoherent; + double Glue; + double IsSingletonF; + double IsSingletonFE; + double LanguageModel; + double LanguageModel_OOV; + double MaxLexFgivenE; + double MaxLexEgivenF; + double PassThrough; + double PassThrough_1; + double PassThrough_2; + double PassThrough_3; + double PassThrough_4; + double PassThrough_5; + double PassThrough_6; + double SampleCountF; + double WordPenalty; + + MSGPACK_DEFINE(CountEF, EgivenFCoherent, Glue, IsSingletonF, IsSingletonFE, LanguageModel, LanguageModel_OOV, MaxLexEgivenF, MaxLexFgivenE, PassThrough, PassThrough_1, PassThrough_2, PassThrough_3, PassThrough_4, PassThrough_5, PassThrough_6, SampleCountF, WordPenalty); +}; + +struct Edge { + int head; + string rule; + vector tails; + Vector f; + double weight; + + MSGPACK_DEFINE(head, rule, tails, f, weight); +}; + +struct Hg { + Vector weights; + vector nodes; + vector edges; + vector rules; + + MSGPACK_DEFINE(weights, nodes, edges, rules); +}; + +int +main(int argc, char** argv) +{ + ifstream ifs(argv[1]); + string str((istreambuf_iterator(ifs)), + (istreambuf_iterator())); + + msgpack::zone zone; + msgpack::object obj; + msgpack::unpack(str.data(), str.size(), NULL, &zone, &obj); + Hg hg; + obj.convert(&hg); + Edge last_edge = hg.edges.back(); + cerr << last_edge.rule.substr(1, 4) << endl; + + return 0; +} + -- cgit v1.2.3