diff options
author | Patrick Simianer <p@simianer.de> | 2014-08-16 21:25:52 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-08-16 21:25:52 +0100 |
commit | 9a0859212de4d1304f9392fe910921227421c8c3 (patch) | |
tree | 1b1276312c83415d7d7d3838ce0347441b71951a /src/test_msgpack.cc | |
parent | 3ba77e3474e39d7970784812f6851a726572f7c7 (diff) |
cleanup
Diffstat (limited to 'src/test_msgpack.cc')
-rw-r--r-- | src/test_msgpack.cc | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/test_msgpack.cc b/src/test_msgpack.cc new file mode 100644 index 0000000..70cf1c8 --- /dev/null +++ b/src/test_msgpack.cc @@ -0,0 +1,81 @@ +#include <iostream> +#include <fstream> +#include <string> + +/* + * http://msgpack.org/ + * + */ +#include <msgpack.hpp> +#include <msgpack/fbuffer.hpp> + +using namespace std; + + +struct Node { + int id; + string cat; + vector<int> 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<int> tails; + Vector f; + double weight; + + MSGPACK_DEFINE(head, rule, tails, f, weight); +}; + +struct Hg { + Vector weights; + vector<Node> nodes; + vector<Edge> edges; + + MSGPACK_DEFINE(weights, nodes, edges); +}; + +int +main(int argc, char** argv) +{ + ifstream ifs(argv[1]); + string str((istreambuf_iterator<char>(ifs)), + (istreambuf_iterator<char>())); + + 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; +} + |