1f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 2f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Licensed under the Apache License, Version 2.0 (the "License"); 3f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// you may not use this file except in compliance with the License. 4f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// You may obtain a copy of the License at 5f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 6f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// http://www.apache.org/licenses/LICENSE-2.0 7f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 8f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Unless required by applicable law or agreed to in writing, software 9f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// distributed under the License is distributed on an "AS IS" BASIS, 10f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// See the License for the specific language governing permissions and 12f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// limitations under the License. 13f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 14f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Copyright 2005-2010 Google, Inc. 15f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// Author: jpr@google.com (Jake Ratkiewicz) 16f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 17f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include <fst/script/fst-class.h> 18f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include <fst/script/script-impl.h> 19f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson#include <fst/script/prune.h> 20f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 21f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonnamespace fst { 22f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonnamespace script { 23f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 24f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 25f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 1 26f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Prune(MutableFstClass *fst, const PruneOptions &opts) { 27f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson PruneArgs1 args(fst, opts); 28f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 29f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson Apply<Operation<PruneArgs1> >("Prune", fst->ArcType(), &args); 30f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} 31f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 32f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 2 33f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Prune(const FstClass &ifst, MutableFstClass *fst, 34f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson const PruneOptions &opts) { 35f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson PruneArgs2 args(ifst, fst, opts); 36f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 37f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson Apply<Operation<PruneArgs2> >("Prune", fst->ArcType(), &args); 38f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} 39f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 40f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 3 41f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Prune(const FstClass &ifst, 42f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson MutableFstClass *ofst, 43f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson const WeightClass& weight_threshold, 44f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson int64 state_threshold, float delta) { 45f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson PruneArgs3 args(ifst, ofst, weight_threshold, state_threshold, delta); 46f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 47f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson Apply<Operation<PruneArgs3> >("Prune", ifst.ArcType(), &args); 48f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} 49f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 50f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 4 51f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Prune(MutableFstClass *fst, const WeightClass& weight_threshold, 52f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson int64 state_threshold, float delta) { 53f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson PruneArgs4 args(fst, weight_threshold, state_threshold, delta); 54f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 55f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson Apply<Operation<PruneArgs4> >("Prune", fst->ArcType(), &args); 56f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} 57f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 58f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 1 59f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, StdArc, PruneArgs1); 60f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, LogArc, PruneArgs1); 61f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs1); 62f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 2 63f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, StdArc, PruneArgs2); 64f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, LogArc, PruneArgs2); 65f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs2); 66f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 3 67f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, StdArc, PruneArgs3); 68f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, LogArc, PruneArgs3); 69f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs3); 70f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 4 71f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, StdArc, PruneArgs4); 72f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, LogArc, PruneArgs4); 73f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Prune, Log64Arc, PruneArgs4); 74f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson 75f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} // namespace script 76f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson} // namespace fst 77