FST  openfst-1.8.3
OpenFst Library
push.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/push.h>
19 
20 #include <cstdint>
21 
22 #include <fst/properties.h>
23 #include <fst/reweight.h>
24 #include <fst/script/fst-class.h>
25 #include <fst/script/script-impl.h>
26 
27 namespace fst {
28 namespace script {
29 
30 void Push(MutableFstClass *fst, ReweightType rew_type, float delta,
31  bool remove_total_weight) {
32  FstPushArgs1 args{fst, rew_type, delta, remove_total_weight};
33  Apply<Operation<FstPushArgs1>>("Push", fst->ArcType(), &args);
34 }
35 
36 void Push(const FstClass &ifst, MutableFstClass *ofst, uint8_t flags,
37  ReweightType rew_type, float delta) {
38  if (!internal::ArcTypesMatch(ifst, *ofst, "Push")) {
39  ofst->SetProperties(kError, kError);
40  return;
41  }
42  FstPushArgs2 args{ifst, ofst, flags, rew_type, delta};
43  Apply<Operation<FstPushArgs2>>("Push", ifst.ArcType(), &args);
44 }
45 
48 
49 } // namespace script
50 } // namespace fst
REGISTER_FST_OPERATION_3ARCS(Compress, CompressArgs)
ReweightType
Definition: reweight.h:35
constexpr uint64_t kError
Definition: properties.h:52
const std::string & ArcType() const final
Definition: fst-class.h:329
bool ArcTypesMatch(const M &m, const N &n, const std::string &op_name)
Definition: script-impl.h:195
std::tuple< const FstClass &, MutableFstClass *, uint8_t, ReweightType, float > FstPushArgs2
Definition: push.h:43
void SetProperties(uint64_t props, uint64_t mask)
Definition: fst-class.h:501
void Push(FstPushArgs1 *args)
Definition: push.h:37
std::tuple< MutableFstClass *, ReweightType, float, bool > FstPushArgs1
Definition: push.h:34