17 "Generate N digit numeric keys (def: use file basenames)");
19 "FAR file format type: one of: \"default\", \"fst\", " 20 "\"stlist\", \"sttable\"");
22 "Allow negative labels (not recommended; may cause conflicts)");
25 "Entry type: one of : " 26 "\"file\" (one FST per file), \"line\" (one FST per line)");
29 "Token type: one of : " 30 "\"symbol\", \"byte\", \"utf8\"");
34 "Each input file contains a list of files to be processed");
35 DEFINE_bool(keep_symbols,
false,
"Store symbol table in the FAR file");
37 "When keep_symbols is true, stores symbol table only for the first" 40 int main(
int argc,
char **argv) {
43 string usage =
"Compiles a set of strings as FSTs and stores them in";
44 usage +=
" a finite-state archive.\n\n Usage:";
46 usage +=
" [in1.txt [[in2.txt ...] out.far]]\n";
49 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
52 std::vector<string> in_fnames;
53 if (FLAGS_file_list_input) {
54 for (
int i = 1; i < argc - 1; ++i) {
55 std::ifstream istrm(argv[i]);
57 while (getline(istrm, str)) in_fnames.push_back(str);
60 for (
int i = 1; i < argc - 1; ++i)
61 in_fnames.push_back(argv[i]);
63 if (in_fnames.empty()) {
64 in_fnames.push_back(argc == 2 && strcmp(argv[1],
"-") != 0 ? argv[1] :
"");
68 argc > 2 && strcmp(argv[argc - 1],
"-") != 0 ? argv[argc - 1] :
"";
72 LOG(ERROR) <<
"Unknown or unsupported FAR entry type: " << FLAGS_entry_type;
78 LOG(ERROR) <<
"Unkonwn or unsupported FAR token type: " << FLAGS_token_type;
85 far_type, FLAGS_generate_keys, entry_type, token_type,
86 FLAGS_symbols, FLAGS_unknown_symbol, FLAGS_keep_symbols,
87 FLAGS_initial_symbols, FLAGS_allow_negative_labels,
88 FLAGS_key_prefix, FLAGS_key_suffix);
DEFINE_int32(generate_keys, 0,"Generate N digit numeric keys (def: use file basenames)")
FarType GetFarType(const string &str)
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
DEFINE_bool(allow_negative_labels, false,"Allow negative labels (not recommended; may cause conflicts)")
bool GetFarTokenType(const string &str, FarTokenType *token_type)
#define SET_FLAGS(usage, argc, argv, rmflags)
DEFINE_string(key_prefix,"","Prefix to append to keys")
int main(int argc, char **argv)
bool GetFarEntryType(const string &str, FarEntryType *entry_type)
void FarCompileStrings(const std::vector< string > &in_fnames, const string &out_fname, const string &arc_type, const string &fst_type, const FarType &far_type, int32 generate_keys, FarEntryType fet, FarTokenType tt, const string &symbols_fname, const string &unknown_symbol, bool keep_symbols, bool initial_symbols, bool allow_negative_labels, const string &key_prefix, const string &key_suffix)