Blame view

tools/openfst-1.6.7/src/script/encode.cc 1.13 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
  // See www.openfst.org for extensive documentation on this weighted
  // finite-state transducer library.
  
  #include <fst/script/fst-class.h>
  #include <fst/encode.h>
  #include <fst/script/encode.h>
  #include <fst/script/script-impl.h>
  
  namespace fst {
  namespace script {
  
  void Encode(MutableFstClass *fst, uint32 flags, bool reuse_encoder,
              const string &coder_fname) {
    EncodeArgs1 args(fst, flags, reuse_encoder, coder_fname);
    Apply<Operation<EncodeArgs1>>("Encode", fst->ArcType(), &args);
  }
  
  void Encode(MutableFstClass *fst, EncodeMapperClass *encoder) {
    if (!internal::ArcTypesMatch(*fst, *encoder, "Encode")) {
      fst->SetProperties(kError, kError);
      return;
    }
    EncodeArgs2 args(fst, encoder);
    Apply<Operation<EncodeArgs2>>("Encode", fst->ArcType(), &args);
  }
  
  REGISTER_FST_OPERATION(Encode, StdArc, EncodeArgs1);
  REGISTER_FST_OPERATION(Encode, LogArc, EncodeArgs1);
  REGISTER_FST_OPERATION(Encode, Log64Arc, EncodeArgs1);
  
  REGISTER_FST_OPERATION(Encode, StdArc, EncodeArgs2);
  REGISTER_FST_OPERATION(Encode, LogArc, EncodeArgs2);
  REGISTER_FST_OPERATION(Encode, Log64Arc, EncodeArgs2);
  
  }  // namespace script
  }  // namespace fst