arcfilter.h revision 4a68b3365c8c50aa93505e99ead2565ab73dcdb0
1// arcfilter.h 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// 16// \file 17// Function objects to restrict which arcs are traversed in an FST. 18 19#ifndef FST_LIB_ARCFILTER_H__ 20#define FST_LIB_ARCFILTER_H__ 21 22namespace fst { 23 24// True for all arcs. 25template <class A> 26class AnyArcFilter { 27public: 28 bool operator()(const A &arc) const { return true; } 29}; 30 31 32// True for (input/output) epsilon arcs. 33template <class A> 34class EpsilonArcFilter { 35public: 36 bool operator()(const A &arc) const { 37 return arc.ilabel == 0 && arc.olabel == 0; 38 } 39}; 40 41} // namespace fst 42 43#endif // FST_LIB_ARCFILTER_H__ 44