Home | History | Annotate | Download | only in script
      1 
      2 // Licensed under the Apache License, Version 2.0 (the "License");
      3 // you may not use this file except in compliance with the License.
      4 // You may obtain a copy of the License at
      5 //
      6 //     http://www.apache.org/licenses/LICENSE-2.0
      7 //
      8 // Unless required by applicable law or agreed to in writing, software
      9 // distributed under the License is distributed on an "AS IS" BASIS,
     10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     11 // See the License for the specific language governing permissions and
     12 // limitations under the License.
     13 //
     14 // Copyright 2005-2010 Google, Inc.
     15 // Author: jpr (at) google.com (Jake Ratkiewicz)
     16 
     17 #include <fst/script/fst-class.h>
     18 #include <fst/script/script-impl.h>
     19 #include <fst/script/relabel.h>
     20 
     21 namespace fst {
     22 namespace script {
     23 
     24 // 1
     25 void Relabel(MutableFstClass *ofst,
     26              const SymbolTable *old_isyms, const SymbolTable *relabel_isyms,
     27              bool attach_new_isyms,
     28              const SymbolTable *old_osyms, const SymbolTable *relabel_osyms,
     29              bool attach_new_osyms) {
     30   RelabelArgs1 args(ofst, old_isyms, relabel_isyms, attach_new_isyms,
     31                          old_osyms, relabel_osyms, attach_new_osyms);
     32   Apply<Operation<RelabelArgs1> >("Relabel", ofst->ArcType(), &args);
     33 }
     34 
     35 // 2
     36 void Relabel(MutableFstClass *ofst,
     37              const vector<pair<int64, int64> > &ipairs,
     38              const vector<pair<int64, int64> > &opairs) {
     39   RelabelArgs2 args(ofst, ipairs, opairs);
     40 
     41   Apply<Operation<RelabelArgs2> >("Relabel", ofst->ArcType(), &args);
     42 }
     43 
     44 // 3
     45 void Relabel(MutableFstClass *fst,
     46              const SymbolTable *new_isymbols,
     47              const SymbolTable *new_osymbols) {
     48   RelabelArgs3 args(fst, new_isymbols, new_osymbols);
     49   Apply<Operation<RelabelArgs3> >("Relabel", fst->ArcType(), &args);
     50 }
     51 
     52 // 1
     53 REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs1);
     54 REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs1);
     55 REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs1);
     56 
     57 // 2
     58 REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs2);
     59 REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs2);
     60 REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs2);
     61 
     62 // 3
     63 REGISTER_FST_OPERATION(Relabel, StdArc, RelabelArgs3);
     64 REGISTER_FST_OPERATION(Relabel, LogArc, RelabelArgs3);
     65 REGISTER_FST_OPERATION(Relabel, Log64Arc, RelabelArgs3);
     66 
     67 }  // namespace script
     68 }  // namespace fst
     69