diff options
author | Chris Dyer <redpony@gmail.com> | 2014-10-19 15:23:31 -0400 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-10-19 15:23:31 -0400 |
commit | fff4dc4a763c6f7fbda61b958ab45641c638d93f (patch) | |
tree | 72b36757d96681b8de16a6a5c6f51ae744cbea7c /decoder/rescore_translator.cc | |
parent | 2bb5f3f4c3c347a2474392993c17cc62653dd133 (diff) |
remove json hypergraph format
Diffstat (limited to 'decoder/rescore_translator.cc')
-rw-r--r-- | decoder/rescore_translator.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/decoder/rescore_translator.cc b/decoder/rescore_translator.cc index 18c83c56..2c5fa9c4 100644 --- a/decoder/rescore_translator.cc +++ b/decoder/rescore_translator.cc @@ -3,6 +3,7 @@ #include <sstream> #include <boost/shared_ptr.hpp> +#include "filelib.h" #include "sentence_metadata.h" #include "hg.h" #include "hg_io.h" @@ -20,16 +21,18 @@ struct RescoreTranslatorImpl { bool Translate(const string& input, const vector<double>& weights, Hypergraph* forest) { - if (input == "{}") return false; - if (input.find("{\"rules\"") == 0) { - istringstream is(input); - Hypergraph src_cfg_hg; - if (!HypergraphIO::ReadFromJSON(&is, forest)) { - cerr << "Parse error while reading HG from JSON.\n"; - abort(); - } - } else { - cerr << "Can only read HG input from JSON: use training/grammar_convert\n"; + istringstream is(input); + string header, fname; + is >> header >> fname; + if (header != "::forest::") { + cerr << "RescoreTranslator: expected input lines of form ::forest:: filename.gz\n"; + abort(); + } + ReadFile rf(fname); + if (!rf) { cerr << "Can't read " << fname << endl; abort(); } + Hypergraph src_cfg_hg; + if (!HypergraphIO::ReadFromBinary(rf.stream(), forest)) { + cerr << "Parse error while reading HG.\n"; abort(); } Hypergraph::TailNodeVector tail(1, forest->nodes_.size() - 1); |