aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fst.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/fst.cc')
-rw-r--r--src/lib/fst.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/fst.cc b/src/lib/fst.cc
index 69bee35..f4bd95f 100644
--- a/src/lib/fst.cc
+++ b/src/lib/fst.cc
@@ -52,6 +52,9 @@ DEFINE_bool(fst_align, false, "Write FST data aligned where appropriate");
DEFINE_string(save_relabel_ipairs, "", "Save input relabel pairs to file");
DEFINE_string(save_relabel_opairs, "", "Save output relabel pairs to file");
+DEFINE_string(fst_read_mode, "read",
+ "Default file reading mode for mappable files");
+
namespace fst {
// Register VectorFst, ConstFst and EditFst for common arcs types
@@ -164,4 +167,27 @@ bool FstHeader::Write(ostream &strm, const string &source) const {
return true;
}
+FstReadOptions::FstReadOptions(const string& src, const FstHeader *hdr,
+ const SymbolTable* isym, const SymbolTable* osym)
+ : source(src), header(hdr), isymbols(isym), osymbols(osym) {
+ mode = ReadMode(FLAGS_fst_read_mode);
+}
+
+FstReadOptions::FstReadOptions(const string& src, const SymbolTable* isym,
+ const SymbolTable* osym)
+ : source(src), header(0), isymbols(isym), osymbols(osym) {
+ mode = ReadMode(FLAGS_fst_read_mode);
+}
+
+FstReadOptions::FileReadMode FstReadOptions::ReadMode(const string &mode) {
+ if (mode == "read") {
+ return READ;
+ }
+ if (mode == "map") {
+ return MAP;
+ }
+ LOG(ERROR) << "Unknown file read mode " << mode;
+ return READ;
+}
+
} // namespace fst