FST  openfst-1.7.1
OpenFst Library
prune.cc
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 
4 #include <fst/script/fst-class.h>
5 #include <fst/script/prune.h>
7 
8 namespace fst {
9 namespace script {
10 
11 void Prune(const FstClass &ifst, MutableFstClass *ofst,
12  const WeightClass &weight_threshold,
13  int64 state_threshold, float delta) {
14  if (!internal::ArcTypesMatch(ifst, *ofst, "Prune") ||
15  !ofst->WeightTypesMatch(weight_threshold, "Prune")) {
16  ofst->SetProperties(kError, kError);
17  return;
18  }
19  PruneArgs1 args(ifst, ofst, weight_threshold, state_threshold, delta);
20  Apply<Operation<PruneArgs1>>("Prune", ifst.ArcType(), &args);
21 }
22 
23 void Prune(MutableFstClass *fst, const WeightClass &weight_threshold,
24  int64 state_threshold, float delta) {
25  if (!fst->WeightTypesMatch(weight_threshold, "Prune")) {
27  return;
28  }
29  PruneArgs2 args(fst, weight_threshold, state_threshold, delta);
30  Apply<Operation<PruneArgs2>>("Prune", fst->ArcType(), &args);
31 }
32 
36 
40 
41 } // namespace script
42 } // namespace fst
bool WeightTypesMatch(const WeightClass &weight, const string &op_name) const
Definition: fst-class.cc:93
std::tuple< const FstClass &, MutableFstClass *, const WeightClass &, int64, float > PruneArgs1
Definition: prune.h:18
std::tuple< MutableFstClass *, const WeightClass &, int64, float > PruneArgs2
Definition: prune.h:30
const string & ArcType() const final
Definition: fst-class.h:290
REGISTER_FST_OPERATION(Compress, StdArc, CompressArgs)
bool ArcTypesMatch(const M &m, const N &n, const string &op_name)
Definition: script-impl.h:176
int64_t int64
Definition: types.h:27
void Prune(PruneArgs1 *args)
Definition: prune.h:21
constexpr uint64 kError
Definition: properties.h:33
void SetProperties(uint64 props, uint64 mask)
Definition: fst-class.h:452