Home | History | Annotate | Download | only in lib
      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 
     22 namespace fst {
     23 
     24 // True for all arcs.
     25 template <class A>
     26 class AnyArcFilter {
     27 public:
     28   bool operator()(const A &arc) const { return true; }
     29 };
     30 
     31 
     32 // True for (input/output) epsilon arcs.
     33 template <class A>
     34 class EpsilonArcFilter {
     35 public:
     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