FST  openfst-1.8.3
OpenFst Library
compile.cc
Go to the documentation of this file.
1 // Copyright 2005-2024 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the 'License');
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an 'AS IS' BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 
18 #include <fst/script/compile.h>
19 
20 #include <istream>
21 #include <memory>
22 #include <string>
23 #include <utility>
24 
25 #include <fst/symbol-table.h>
26 #include <fst/script/fst-class.h>
27 #include <fst/script/script-impl.h>
28 
29 namespace fst {
30 namespace script {
31 
32 void Compile(std::istream &istrm, const std::string &source,
33  const std::string &dest, const std::string &fst_type,
34  const std::string &arc_type, const SymbolTable *isyms,
35  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep,
36  bool ikeep, bool okeep, bool nkeep) {
37  std::unique_ptr<FstClass> fst(CompileInternal(istrm, source, fst_type,
38  arc_type, isyms, osyms, ssyms,
39  accep, ikeep, okeep, nkeep));
40  fst->Write(dest);
41 }
42 
43 std::unique_ptr<FstClass> CompileInternal(
44  std::istream &istrm, const std::string &source, const std::string &fst_type,
45  const std::string &arc_type, const SymbolTable *isyms,
46  const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, bool ikeep,
47  bool okeep, bool nkeep) {
48  FstCompileInnerArgs iargs{istrm,
49  source,
50  fst_type,
51  isyms,
52  osyms,
53  ssyms,
54  accep,
55  ikeep,
56  okeep,
57  nkeep};
58  FstCompileArgs args(iargs);
59  Apply<Operation<FstCompileArgs>>("CompileInternal", arc_type, &args);
60  return std::move(args.retval);
61 }
62 
63 // This registers form 2; 1 does not require registration.
65 
66 } // namespace script
67 } // namespace fst
REGISTER_FST_OPERATION_3ARCS(Compress, CompressArgs)
void Compile(std::istream &istrm, const std::string &source, const std::string &dest, const std::string &fst_type, const std::string &arc_type, const SymbolTable *isyms, const SymbolTable *osyms, const SymbolTable *ssyms, bool accep, bool ikeep, bool okeep, bool nkeep)
Definition: compile.cc:32
void CompileInternal(FstCompileArgs *args)
Definition: compile.h:64