Skip to content
This repository
Newer
Older
100644 40 lines (30 sloc) 1.615 kb
01727218 »
2010-06-22 initial checkin
1 #ifndef _HG_IO_H_
2 #define _HG_IO_H_
3
4 #include <iostream>
6da0534d »
2012-05-08 Output separate files for target hypergraphs.
5 #include <string>
01727218 »
2010-06-22 initial checkin
6 #include "lattice.h"
f9859ad4 »
2010-08-02 fake tdict names for non-ids, push viterbi cost to root in hg, store …
7
01727218 »
2010-06-22 initial checkin
8 class Hypergraph;
9
10 struct HypergraphIO {
11
12 // the format is basically a list of nodes and edges in topological order
13 // any edge you read, you must have already read its tail nodes
14 // any node you read, you must have already read its incoming edges
15 // this may make writing a bit more challenging if your forest is not
16 // topologically sorted (but that probably doesn't happen very often),
17 // but it makes reading much more memory efficient.
18 // see test_data/small.json.gz for an email encoding
19 static bool ReadFromJSON(std::istream* in, Hypergraph* out);
20
21 // if remove_rules is used, the hypergraph is serialized without rule information
22 // (so it only contains structure and feature information)
23 static bool WriteToJSON(const Hypergraph& hg, bool remove_rules, std::ostream* out);
24
25 static void WriteAsCFG(const Hypergraph& hg);
26
feab7be0 »
2012-02-12 Target-side only output format
27 // Write only the target size information in bottom-up order.
6da0534d »
2012-05-08 Output separate files for target hypergraphs.
28 static void WriteTarget(const std::string &base, unsigned int sent_id, const Hypergraph& hg);
feab7be0 »
2012-02-12 Target-side only output format
29
01727218 »
2010-06-22 initial checkin
30 // serialization utils
31 static void ReadFromPLF(const std::string& in, Hypergraph* out, int line = 0);
32 // return PLF string representation (undefined behavior on non-lattices)
33 static std::string AsPLF(const Hypergraph& hg, bool include_global_parentheses = true);
6001b81e »
2012-04-03 bayes lattice scoring
34 static std::string AsPLF(const Lattice& lat, bool include_global_parentheses = true);
01727218 »
2010-06-22 initial checkin
35 static void PLFtoLattice(const std::string& plf, Lattice* pl);
36 static std::string Escape(const std::string& s); // PLF helper
37 };
38
39 #endif
Something went wrong with that request. Please try again.