44 std::string usage =
"Finds shortest distance(s) in an FST.\n\n Usage: ";
46 usage +=
" [in.fst [distance.txt]]\n";
49 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
55 const std::string in_name =
56 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
57 const std::string out_name =
58 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
60 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
63 std::vector<WeightClass> distance;
67 LOG(ERROR) << argv[0] <<
": Unknown or unsupported queue type: " 68 << FST_FLAGS_queue_type;
72 if (FST_FLAGS_reverse && queue_type !=
AUTO_QUEUE) {
73 LOG(ERROR) << argv[0] <<
": Can't use non-default queue with reverse";
77 if (FST_FLAGS_reverse) {
81 const s::ShortestDistanceOptions opts(queue_type, s::ArcFilterType::ANY,
void ShowUsage(bool long_usage=true)
bool WritePotentials(const std::string &source, const std::vector< WeightClass > &potentials)
DECLARE_string(queue_type)
#define SET_FLAGS(usage, argc, argv, rmflags)
int fstshortestdistance_main(int argc, char **argv)
void ShortestDistance(const Fst< Arc > &fst, std::vector< typename Arc::Weight > *distance, const ShortestDistanceOptions &opts)
bool GetQueueType(std::string_view str, QueueType *queue_type)