Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <fst/script/convert.h>
00024
00025 DEFINE_string(fst_type, "vector", "Output FST type");
00026
00027 int main(int argc, char **argv) {
00028 namespace s = fst::script;
00029 using fst::script::FstClass;
00030
00031 string usage = "Converts an FST to another type.\n\n Usage: ";
00032 usage += argv[0];
00033 usage += " [in.fst [out.fst]]\n";
00034
00035 std::set_new_handler(FailedNewHandler);
00036 SetFlags(usage.c_str(), &argc, &argv, true);
00037 if (argc > 3) {
00038 ShowUsage();
00039 return 1;
00040 }
00041
00042 string in_name = (argc > 1 && strcmp(argv[1], "-") != 0) ? argv[1] : "";
00043 string out_name = argc > 2 ? argv[2] : "";
00044
00045 FstClass *ifst = FstClass::Read(in_name);
00046 if (!ifst) return 1;
00047
00048 FstClass *ofst = ifst;
00049 if (!ofst) return 1;
00050
00051 if (ofst->FstType() != FLAGS_fst_type) {
00052 ofst = s::Convert(*ifst, FLAGS_fst_type);
00053 }
00054
00055 ofst->Write(out_name);
00056
00057 return 0;
00058 }
00059