32 #include <string_view> 37 "Verify FST properties queried by TestProperties");
39 DEFINE_bool(fst_default_cache_gc,
true,
"Enable garbage collection of cache");
42 "Cache byte size that triggers garbage collection");
44 DEFINE_bool(fst_align,
false,
"Write FST data aligned where appropriate");
46 DEFINE_string(save_relabel_ipairs,
"",
"Save input relabel pairs to file");
47 DEFINE_string(save_relabel_opairs,
"",
"Save output relabel pairs to file");
50 "Default file reading mode for mappable files");
59 if (rewind) pos = strm.tellg();
60 int32_t magic_number = 0;
63 LOG(ERROR) <<
"FstHeader::Read: Bad FST header: " << source
64 <<
". Magic number not matched. Got: " << magic_number;
65 if (rewind) strm.seekg(pos);
77 LOG(ERROR) <<
"FstHeader::Read: Read failed: " << source;
80 if (rewind) strm.seekg(pos);
99 std::ostringstream ostrm;
100 ostrm <<
"fsttype: \"" << fsttype_ <<
"\" arctype: \"" << arctype_
101 <<
"\" version: \"" << version_ <<
"\" flags: \"" << flags_
102 <<
"\" properties: \"" << properties_ <<
"\" start: \"" << start_
103 <<
"\" numstates: \"" << numstates_ <<
"\" numarcs: \"" << numarcs_
117 read_osymbols(true) {
127 if (mode ==
"read")
return READ;
128 if (mode ==
"map")
return MAP;
129 LOG(ERROR) <<
"Unknown file read mode " <<
mode;
134 std::ostringstream ostrm;
135 ostrm <<
"source: \"" <<
source <<
"\" mode: \"" 136 << (
mode ==
READ ?
"READ" :
"MAP") <<
"\" read_isymbols: \"" 137 << (
read_isymbols ?
"true" :
"false") <<
"\" read_osymbols: \"" 139 << (
header ?
"set" :
"null") <<
"\" isymbols: \"" 140 << (
isymbols ?
"set" :
"null") <<
"\" osymbols: \"" 141 << (
osymbols ?
"set" :
"null") <<
"\"";
constexpr int32_t kFstMagicNumber
const SymbolTable * osymbols
std::ostream & WriteType(std::ostream &strm, const T t)
std::string DebugString() const
static FileReadMode ReadMode(std::string_view mode)
DEFINE_string(save_relabel_ipairs,"","Save input relabel pairs to file")
DEFINE_int64(fst_default_cache_gc_limit, 1<< 20LL,"Cache byte size that triggers garbage collection")
std::istream & ReadType(std::istream &strm, T *t)
const SymbolTable * isymbols
DEFINE_bool(fst_verify_properties, false,"Verify FST properties queried by TestProperties")
FstReadOptions(std::string_view source="<unspecified>", const FstHeader *header=nullptr, const SymbolTable *isymbols=nullptr, const SymbolTable *osymbols=nullptr)