00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022
00023 #include <iostream>
00024 #include <fstream>
00025 #include <fst/main.h>
00026
00027
00028 DEFINE_bool(acceptor, false, "Input in acceptor format");
00029 DEFINE_string(arc_filter, "any", "Arc filter: one of :\
00030 \"any\", \"epsilon\", \"iepsilon\", \"oepsilon\"");
00031 DEFINE_string(arc_type, "standard", "Output arc type");
00032 DEFINE_bool(connect, true, "Trim output");
00033 DEFINE_double(delta, fst::kDelta, "Comparison/quantization delta");
00034 DEFINE_string(fst_type, "vector", "Output FST type");
00035 DEFINE_string(isymbols, "", "Input label symbol table");
00036 DEFINE_string(osymbols, "", "Output label symbol table");
00037 DEFINE_bool(reverse, false, "Perform in the reverse direction");
00038 DEFINE_string(ssymbols, "", "State label symbol table");
00039 DEFINE_bool(to_final, false, "Push/reweight to final (vs. to initial) states");
00040 DEFINE_string(weight, "", "Weight parameter");
00041 DEFINE_int64(nstate, fst::kNoStateId, "State number parameter");
00042 DEFINE_bool(allow_negative_labels, false,
00043 "Allow negative labels (not recommended; may cause conflicts)");
00044
00045
00046 DEFINE_string(sort_type, "ilabel",
00047 "Comparison method, one of: \"ilabel\", \"olabel\"");
00048
00049
00050 DEFINE_bool(closure_plus, false,
00051 "Do not add the empty path (T+ instead of T*)");
00052
00053
00054 DEFINE_bool(keep_isymbols, false, "Store input label symbol table with FST");
00055 DEFINE_bool(keep_osymbols, false, "Store output label symbol table with FST");
00056 DEFINE_bool(keep_state_numbering, false, "Do not renumber input states");
00057
00058
00059 DEFINE_string(compose_filter, "sequence", "Compose filter");
00060
00061
00062 DEFINE_int32(fontsize, 14, "Set fontsize");
00063 DEFINE_double(height, 11, "Set height");
00064 DEFINE_double(width, 8.5, "Set width");
00065 DEFINE_bool(portrait, false, "Portrait mode (def: landscape)");
00066 DEFINE_bool(vertical, false, "Draw bottom-to-top instead of left-to-right");
00067 DEFINE_string(title, "", "Set figure title");
00068 DEFINE_int32(precision, 5, "Set precision (number of char/float)");
00069 DEFINE_double(nodesep, 0.25,
00070 "Set minimum separation between nodes (see dot documentation)");
00071 DEFINE_double(ranksep, 0.40,
00072 "Set minimum separation between ranks (see dot documentation)");
00073
00074
00075 DEFINE_bool(pipe, false, "Send info to stderr, input to stdout");
00076 DEFINE_bool(test_properties, true,
00077 "Compute property values (if unknown to FST)");
00078
00079
00080 DEFINE_bool(numeric, false, "Print numeric labels");
00081 DEFINE_string(save_isymbols, "", "Save input symbol table to file");
00082 DEFINE_string(save_osymbols, "", "Save output symbol table to file");
00083 DEFINE_bool(show_weight_one, false,
00084 "Print/draw arc weights and final weights equal to Weight::One()");
00085
00086
00087 DEFINE_bool(project_output, false, "Project on output (vs. input)");
00088
00089
00090 DEFINE_bool(random, false,
00091 "Test equivalence by randomly selecting paths in the input FSTs");
00092
00094 DEFINE_bool(encode_labels, false, "Encode output labels");
00095 DEFINE_bool(encode_weights, false, "Encode weights");
00096 DEFINE_bool(encode_reuse, false, "Re-use existing codex");
00097 DEFINE_bool(decode, false, "Decode labels and/or weights");
00098
00099
00100 DEFINE_bool(eps_norm_output, false, "Normalize output epsilons");
00101
00102
00103 DEFINE_string(map_type, "identity",
00104 "Map operation, one of: \"identity\", \"invert\",\
00105 \"plus (--weight)\", \"quantize (--delta)\", \"rmweight\",\
00106 \"superfinal\", \"times (--weight)\"\n");
00107
00108
00109
00110
00111 DEFINE_string(relabel_isymbols, "", "Input symbol set to relabel to");
00112 DEFINE_string(relabel_osymbols, "", "Ouput symbol set to relabel to");
00113
00114
00115
00116 DEFINE_string(relabel_ipairs, "", "Input relabel pairs (numeric)");
00117 DEFINE_string(relabel_opairs, "", "Output relabel pairs (numeric)");
00118
00119
00120 DEFINE_bool(push_weights, false, "Push weights");
00121 DEFINE_bool(push_labels, false, "Push output labels");
00122
00123
00124 DEFINE_int32(max_length, INT_MAX, "Maximum path length");
00125 DEFINE_int32(npath, 1, "Number of paths to generate");
00126 DEFINE_int32(seed, time(0), "Random seed");
00127 DEFINE_string(select, "uniform", "Selection type: one of:\
00128 \"uniform\", \"log_prob (when appropriate)\"");
00129
00130
00131 DEFINE_int64(nshortest, 1, "Return N-shortest paths");
00132 DEFINE_bool(unique, false, "Return unique strings");
00133
00134
00135 DEFINE_bool(epsilon_on_replace, false, "Create an espilon arc when recursing");
00136
00137
00138 DEFINE_int64(subsequential_label, 0,
00139 "Input label of arc corresponding to residual final output when\
00140 producing a subsequential transducer");
00141
00142 namespace fst {
00143
00144 FstOnceType FstMainRegister::register_init_ = FST_ONCE_INIT;
00145
00146 Mutex *FstMainRegister::register_lock_ = 0;
00147
00148 FstMainRegister *FstMainRegister::register_ = 0;
00149
00150
00151
00152 int CallFstMain(const string &mtype, int argc, char **argv, string atype) {
00153 const char *filename = "standard input";
00154 istream *strm = &std::cin;
00155 FstReadOptions opts;
00156 FstHeader hdr;
00157 if (atype == "") {
00158 if (argc > 1 && strcmp(argv[1], "-") != 0) {
00159 filename = argv[1];
00160 strm = new ifstream(filename);
00161 if (!*strm) {
00162 LOG(ERROR) << argv[0] << ": Can't open file: " << filename;
00163 return 1;
00164 }
00165 }
00166 if (!hdr.Read(*strm, filename))
00167 return 1;
00168 atype = hdr.ArcType();
00169 opts.source = filename;
00170 opts.header = &hdr;
00171 }
00172
00173 FstMainRegister *registr = FstMainRegister::GetRegister();
00174 const FstMainRegister::Main main = registr->GetMain(mtype, atype);
00175 if (!main) {
00176 LOG(ERROR) << argv[0] << ": Bad or unknown arc type \"" << atype
00177 << "\" for this operation (" << mtype << ")";
00178 return 1;
00179 }
00180 int ret = main(argc, argv, *strm, opts);
00181 if (strm != &std::cin)
00182 delete strm;
00183 return ret;
00184 }
00185
00186 }