47 "Creates binary FSTs from simple text format.\n\n Usage: ";
49 usage +=
" [text.fst [binary.fst]]\n";
51 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
57 std::string source =
"standard input";
59 if (argc > 1 && strcmp(argv[1],
"-") != 0) {
62 LOG(ERROR) << argv[0] <<
": Open failed, file = " << argv[1];
67 std::istream &istrm = fstrm.is_open() ? fstrm : std::cin;
69 std::unique_ptr<const SymbolTable> isyms;
70 if (!FST_FLAGS_isymbols.empty()) {
72 SymbolTable::ReadText(FST_FLAGS_isymbols,
73 FST_FLAGS_fst_field_separator));
77 std::unique_ptr<const SymbolTable> osyms;
78 if (!FST_FLAGS_osymbols.empty()) {
80 SymbolTable::ReadText(FST_FLAGS_osymbols,
81 FST_FLAGS_fst_field_separator));
85 std::unique_ptr<const SymbolTable> ssyms;
86 if (!FST_FLAGS_ssymbols.empty()) {
88 SymbolTable::ReadText(FST_FLAGS_ssymbols,
89 FST_FLAGS_fst_field_separator));
93 const std::string dest = argc > 2 && strcmp(argv[2],
"-") != 0 ? argv[2] :
"";
95 s::Compile(istrm, source, dest, FST_FLAGS_fst_type,
96 FST_FLAGS_arc_type, isyms.get(), osyms.get(),
97 ssyms.get(), FST_FLAGS_acceptor,
98 FST_FLAGS_keep_isymbols,
99 FST_FLAGS_keep_osymbols,
100 FST_FLAGS_keep_state_numbering);
void ShowUsage(bool long_usage=true)
int fstcompile_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Compile(std::istream &istrm, const std::string &source, const std::string &dest, const std::string &fst_type, const std::string &arc_type, const SymbolTable *isyms, const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, bool ikeep, bool okeep, bool nkeep)