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@google.com (Jake Ratkiewicz)
16
17 #include <fst/script/fst-class.h>
18 #include <fst/script/script-impl.h>
19 #include <fst/script/shortest-distance.h>
20
21 namespace fst {
22 namespace script {
23
24 // 1
ShortestDistance(const FstClass & fst,vector<WeightClass> * distance,const ShortestDistanceOptions & opts)25 void ShortestDistance(const FstClass &fst, vector<WeightClass> *distance,
26 const ShortestDistanceOptions &opts) {
27 ShortestDistanceArgs1 args(fst, distance, opts);
28
29 Apply<Operation<ShortestDistanceArgs1> >("ShortestDistance", fst.ArcType(),
30 &args);
31 }
32
33 // 2
ShortestDistance(const FstClass & ifst,vector<WeightClass> * distance,bool reverse,double delta)34 void ShortestDistance(const FstClass &ifst, vector<WeightClass> *distance,
35 bool reverse, double delta) {
36 ShortestDistanceArgs2 args(ifst, distance, reverse, delta);
37
38 Apply<Operation<ShortestDistanceArgs2> >("ShortestDistance", ifst.ArcType(),
39 &args);
40 }
41
42 // 3
ShortestDistance(const FstClass & ifst)43 WeightClass ShortestDistance(const FstClass &ifst) {
44 ShortestDistanceArgs3 args(ifst);
45
46 Apply<Operation<ShortestDistanceArgs3> >("ShortestDistance", ifst.ArcType(),
47 &args);
48
49 return args.retval;
50 }
51
52 REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs1);
53 REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs1);
54 REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs1);
55
56 REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs2);
57 REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs2);
58 REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs2);
59
60 REGISTER_FST_OPERATION(ShortestDistance, StdArc, ShortestDistanceArgs3);
61 REGISTER_FST_OPERATION(ShortestDistance, LogArc, ShortestDistanceArgs3);
62 REGISTER_FST_OPERATION(ShortestDistance, Log64Arc, ShortestDistanceArgs3);
63
64
65 } // namespace script
66 } // namespace fst
67