Blame view
tools/openfst-1.6.7/src/extensions/far/script-impl.cc
1.01 KB
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. // // Definitions and functions for invoking and using Far main functions that // support multiple and extensible arc types. #include <fst/extensions/far/script-impl.h> #include <string> #include <fst/extensions/far/far.h> #include <fstream> namespace fst { namespace script { string LoadArcTypeFromFar(const string &far_fname) { FarHeader hdr; if (!hdr.Read(far_fname)) { LOG(ERROR) << "Error reading FAR: " << far_fname; return ""; } string atype = hdr.ArcType(); if (atype == "unknown") { LOG(ERROR) << "Empty FST archive: " << far_fname; return ""; } return atype; } string LoadArcTypeFromFst(const string &fst_fname) { FstHeader hdr; std::ifstream in(fst_fname, std::ios_base::in | std::ios_base::binary); if (!hdr.Read(in, fst_fname)) { LOG(ERROR) << "Error reading FST: " << fst_fname; return ""; } return hdr.ArcType(); } } // namespace script } // namespace fst |