FST  openfst-1.8.3
OpenFst Library
relabel.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/relabel.h>
19 
20 #include <cstdint>
21 #include <string>
22 #include <utility>
23 #include <vector>
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 Relabel(MutableFstClass *ofst, const SymbolTable *old_isyms,
33  const SymbolTable *relabel_isyms,
34  const std::string &unknown_isymbol, bool attach_new_isyms,
35  const SymbolTable *old_osyms, const SymbolTable *relabel_osyms,
36  const std::string &unknown_osymbol, bool attach_new_osyms) {
37  FstRelabelArgs1 args{ofst,
38  old_isyms,
39  relabel_isyms,
40  unknown_isymbol,
41  attach_new_isyms,
42  old_osyms,
43  relabel_osyms,
44  unknown_osymbol,
45  attach_new_osyms};
46  Apply<Operation<FstRelabelArgs1>>("Relabel", ofst->ArcType(), &args);
47 }
48 
50  const std::vector<std::pair<int64_t, int64_t>> &ipairs,
51  const std::vector<std::pair<int64_t, int64_t>> &opairs) {
52  FstRelabelArgs2 args{ofst, ipairs, opairs};
53  Apply<Operation<FstRelabelArgs2>>("Relabel", ofst->ArcType(), &args);
54 }
55 
58 
59 } // namespace script
60 } // namespace fst
REGISTER_FST_OPERATION_3ARCS(Compress, CompressArgs)
const std::string & ArcType() const final
Definition: fst-class.h:329
void Relabel(FstRelabelArgs1 *args)
Definition: relabel.h:42
std::tuple< MutableFstClass *, const SymbolTable *, const SymbolTable *, const std::string &, bool, const SymbolTable *, const SymbolTable *, const std::string &, bool > FstRelabelArgs1
Definition: relabel.h:39
std::tuple< MutableFstClass *, const std::vector< std::pair< int64_t, int64_t >> &, const std::vector< std::pair< int64_t, int64_t >> & > FstRelabelArgs2
Definition: relabel.h:52