Blame view

tools/openfst-1.6.7/src/script/prune.cc 1.4 KB
8dcb6dfcb   Yannick Estève   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  // See www.openfst.org for extensive documentation on this weighted
  // finite-state transducer library.
  
  #include <fst/script/fst-class.h>
  #include <fst/script/prune.h>
  #include <fst/script/script-impl.h>
  
  namespace fst {
  namespace script {
  
  void Prune(const FstClass &ifst, MutableFstClass *ofst,
             const WeightClass &weight_threshold,
             int64 state_threshold, float delta) {
    if (!internal::ArcTypesMatch(ifst, *ofst, "Prune") ||
        !ofst->WeightTypesMatch(weight_threshold, "Prune")) {
      ofst->SetProperties(kError, kError);
      return;
    }
    PruneArgs1 args(ifst, ofst, weight_threshold, state_threshold, delta);
    Apply<Operation<PruneArgs1>>("Prune", ifst.ArcType(), &args);
  }
  
  void Prune(MutableFstClass *fst, const WeightClass &weight_threshold,
             int64 state_threshold, float delta) {
    if (!fst->WeightTypesMatch(weight_threshold, "Prune")) {
      fst->SetProperties(kError, kError);
      return;
    }
    PruneArgs2 args(fst, weight_threshold, state_threshold, delta);
    Apply<Operation<PruneArgs2>>("Prune", fst->ArcType(), &args);
  }
  
  REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs1);
  REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs1);
  REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs1);
  
  REGISTER_FST_OPERATION(Prune, StdArc, PruneArgs2);
  REGISTER_FST_OPERATION(Prune, LogArc, PruneArgs2);
  REGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs2);
  
  }  // namespace script
  }  // namespace fst