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/relabel.h>
20f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
21f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonnamespace fst {
22f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonnamespace script {
23f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
24f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 1
25f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Relabel(MutableFstClass *ofst,
26f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const SymbolTable *old_isyms, const SymbolTable *relabel_isyms,
27f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             bool attach_new_isyms,
28f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const SymbolTable *old_osyms, const SymbolTable *relabel_osyms,
29f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             bool attach_new_osyms) {
30f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  RelabelArgs1 args(ofst, old_isyms, relabel_isyms, attach_new_isyms,
31f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson                         old_osyms, relabel_osyms, attach_new_osyms);
32f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  Apply<Operation<RelabelArgs1> >("Relabel", ofst->ArcType(), &args);
33f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson}
34f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
35f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 2
36f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Relabel(MutableFstClass *ofst,
37f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const vector<pair<int64, int64> > &ipairs,
38f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const vector<pair<int64, int64> > &opairs) {
39f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  RelabelArgs2 args(ofst, ipairs, opairs);
40f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
41f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  Apply<Operation<RelabelArgs2> >("Relabel", ofst->ArcType(), &args);
42f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson}
43f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
44f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 3
45f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodsonvoid Relabel(MutableFstClass *fst,
46f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const SymbolTable *new_isymbols,
47f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson             const SymbolTable *new_osymbols) {
48f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  RelabelArgs3 args(fst, new_isymbols, new_osymbols);
49f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson  Apply<Operation<RelabelArgs3> >("Relabel", fst->ArcType(), &args);
50f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson}
51f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
52f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 1
53f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs1);
54f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs1);
55f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs1);
56f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
57f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 2
58f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs2);
59f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs2);
60f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs2);
61f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
62f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson// 3
63f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs3);
64f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs3);
65f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian HodsonREGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs3);
66f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson
67f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson}  // namespace script
68f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2Ian Hodson}  // namespace fst
69