Cambridge SMT System
fstutils.multiepsiloncompose.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use these files except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 // Copyright 2012 - Gonzalo Iglesias, AdriĆ  de Gispert, William Byrne
14 
15 #ifndef MULTIEPSILONCOMPOSE_HPP
16 #define MULTIEPSILONCOMPOSE_HPP
17 
24 namespace fst {
25 
34 template <class Arc>
35 ComposeFst<Arc> MultiEpsilonCompose ( const Fst<Arc>& fstlhs
36  , const Fst<Arc>& fstrhs
37  , const std::vector<typename Arc::Label>& multiepsilons ) {
38  typedef MultiEpsMatcher< Matcher<Fst<Arc> > > MultiEpsilonMatcher;
39  typedef ComposeFstOptions<Arc, MultiEpsilonMatcher> COptions;
40  MultiEpsilonMatcher *mem1 = new MultiEpsilonMatcher ( fstlhs, MATCH_OUTPUT,
41  kMultiEpsList );
42  MultiEpsilonMatcher *mem2 = new MultiEpsilonMatcher ( fstrhs, MATCH_NONE,
43  kNoLabel );
44  for ( std::size_t i = 0; i < multiepsilons.size(); ++i ) {
45  mem1->AddMultiEpsLabel ( multiepsilons[i] );
46  // mem2->AddMultiEpsLabel(multiepsilons[i]);
47  }
48  // MultiEpsilonFilter *filter = new MultiEpsilonFilter(fstlhs, fstrhs, mem1, mem2, true);
49  COptions copts (
50  CacheOptions(),
51  mem1,
52  mem2
53  );
54  return ComposeFst<Arc> ( fstlhs, fstrhs, copts );
55 }
56 
57 }; //namespaces
58 
59 #endif
Definition: fstio.hpp:27
ComposeFst< Arc > MultiEpsilonCompose(const Fst< Arc > &fstlhs, const Fst< Arc > &fstrhs, const std::vector< typename Arc::Label > &multiepsilons)
Convenience function that performs composition with multiple epsilons.