15 #ifndef NLP_GRM2_BAUMWELCH_DECODE_H_ 16 #define NLP_GRM2_BAUMWELCH_DECODE_H_ 27 #include <fst/extensions/far/far.h> 28 #include <fst/compact-fst.h> 29 #include <fst/fst-decl.h> 30 #include <fst/project.h> 31 #include <fst/rmepsilon.h> 32 #include <fst/shortest-path.h> 33 #include <fst/statesort.h> 34 #include <fst/vector-fst.h> 35 #include <fst/weight.h> 49 using StateId =
typename Arc::StateId;
51 std::vector<StateId> order(fst->NumStates());
52 std::iota(order.rbegin(), order.rend(), 0);
53 StateSort(fst, order);
60 if constexpr (IsPath<typename Arc::Weight>::value) {
61 ShortestPath(ifst, &ofst);
72 VectorFst<Arc> lattice;
73 Project(ifst, &lattice, ProjectType::INPUT);
76 if constexpr (IsPath<typename Arc::Weight>::value) {
77 ShortestPath(lattice, &ofst);
82 return CompactWeightedStringFst<Arc>(ofst);
89 void Decode(FarReader<Arc> &input, FarReader<Arc> &output,
90 const Fst<Arc> &model, FarWriter<Arc> &hypotext) {
91 while (!input.Done() && !output.Done()) {
93 if (input.Type() == FarType::FST) {
94 hypotext.Add(output.GetKey(),
97 hypotext.Add(input.GetKey() +
"_" + output.GetKey(),
107 #endif // NLP_GRM2_BAUMWELCH_DECODE_H_
CompactWeightedStringFst< Arc > DecodeDecipherment(const Fst< Arc > &ifst)
VectorFst< Arc > DecodePair(const Fst< Arc > &ifst)
void Decode(FarReader< Arc > &input, FarReader< Arc > &output, const Fst< Arc > &model, FarWriter< Arc > &hypotext)
void ReverseStateNumbering(MutableFst< Arc > *fst)
void AStarSingleShortestString(const Fst< Arc > &ifst, MutableFst< Arc > *ofst, float delta=kShortestDelta)