From 08e9a6f71c80fc7327d1758312b40bd5ba763dc9 Mon Sep 17 00:00:00 2001
From: Patrick Simianer
Date: Sun, 20 Jul 2014 15:08:12 +0200
Subject: a lot
---
fast/make_paks.cc | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
(limited to 'fast/make_paks.cc')
diff --git a/fast/make_paks.cc b/fast/make_paks.cc
index 6fe7fae..c0fee90 100644
--- a/fast/make_paks.cc
+++ b/fast/make_paks.cc
@@ -1,26 +1,25 @@
#include
#include
#include
+#include
#include
-#include
#include
-#include
#include "json-cpp.hpp"
-#include "hypergraph.hh"
#include "dummyvector.h"
+#include "hypergraph.hh"
using namespace std;
struct DummyNode {
- int id;
+ size_t id;
string cat;
- vector span;
+ vector span;
};
struct DummyEdge {
- int head;
+ size_t head;
string rule;
vector tails;
DummyVector f;
@@ -57,15 +56,13 @@ serialize(jsoncpp::Stream& stream, DummyVector& o)
fields(o, stream, "EgivenFCoherent", o.EgivenFCoherent, "SampleCountF", o.SampleCountF, "CountEF", o.CountEF, "MaxLexFgivenE", o.MaxLexFgivenE, "MaxLexEgivenF", o.MaxLexEgivenF, "IsSingletonF", o.IsSingletonF, "IsSingletonFE", o.IsSingletonFE, "LanguageModel", o.LanguageModel, "LanguageModel_OOV", o.LanguageModel_OOV, "PassThrough", o.PassThrough, "PassThrough_1", o.PassThrough_1, "PassThrough_2", o.PassThrough_2, "PassThrough_3", o.PassThrough_3, "PassThrough_4", o.PassThrough_4, "PassThrough_5", o.PassThrough_5, "PassThrough_6", o.PassThrough_6, "WordPenalty", o.WordPenalty, "Glue", o.Glue);
}
-
-
int
main(int argc, char** argv)
{
+ // read from json
ifstream ifs(argv[1]);
string json_str((istreambuf_iterator(ifs) ),
(istreambuf_iterator()));
-
DummyHg hg;
vector nodes;
hg.nodes = nodes;
@@ -75,19 +72,19 @@ main(int argc, char** argv)
hg.weights = w;
jsoncpp::parse(hg, json_str);
+ // convert objects
vector nodes_;
for (auto it = hg.nodes.begin(); it != hg.nodes.end(); ++it) {
- Hg::Node* n = new Hg::Node;
- n->id = it->id;
+ Hg::Node* n = new Hg::Node;
+ n->id = it->id;
n->symbol = it->cat;
n->left = it->span[0];
n->right = it->span[1];
nodes_.push_back(n);
}
-
vector edges_;
for (auto it = hg.edges.begin(); it != hg.edges.end(); ++it) {
- Hg::Edge* e = new Hg::Edge;
+ Hg::Edge* e = new Hg::Edge;
e->head_id_ = it->head;
e->tails_ids_ = it->tails;
e->score = it->weight;
@@ -96,6 +93,7 @@ main(int argc, char** argv)
edges_.push_back(e);
}
+ // write to msgpack
FILE* file = fopen(argv[2], "wb");
msgpack::fbuffer fbuf(file);
msgpack::pack(fbuf, hg.nodes.size());
--
cgit v1.2.3