15 #ifndef FSTUTILS_MULTIUNION_HPP 16 #define FSTUTILS_MULTIUNION_HPP 37 std::vector< boost::shared_ptr< Fst<Arc>
const > > fsts_;
47 inline void Add ( boost::shared_ptr< Fst<Arc>
const >
fst ) {
48 fsts_.push_back (
fst );
52 inline void Add ( Fst<Arc>
const *
fst ) {
53 fsts_.push_back ( boost::shared_ptr< Fst<Arc>
const > ( fst ) );
61 if ( !fsts_.size() )
return NULL;
62 VectorFst<Arc> * aux2 = NULL;
63 if ( fsts_.size() > 1 ) {
64 boost::scoped_ptr< UnionFst<Arc> > aux (
new UnionFst<Arc> ( *fsts_[0],
66 for ( uint k = 2; k < fsts_.size(); ++k ) Union ( & ( *aux ), *fsts_[k] );
67 aux2 =
new VectorFst<Arc> ( *aux );
68 }
else aux2 =
new VectorFst<Arc> ( *fsts_[0] );
85 const uint unionindex_;
89 std::vector< pair< typename Arc::Label, const Fst<Arc> * > > pairlabelfsts_;
90 std::vector<boost::shared_ptr< Fst<Arc>
const > > fsts_;
96 unionindex_ ( 1000000000 ) {
100 head_.SetFinal ( 1, Arc::Weight::One() );
101 pairlabelfsts_.push_back ( pair<
typename Arc::Label,
const Fst<Arc> * >
102 ( unionindex_, &head_ ) );
109 inline void Add ( Fst<Arc>
const *
fst ) {
111 fsts_.push_back ( boost::shared_ptr< Fst<Arc>
const > ( fst ) );
113 head_.AddArc ( 0, Arc ( unionindex_ + counter_, unionindex_ + counter_,
114 Arc::Weight::One(), 1 ) );
115 pairlabelfsts_.push_back ( pair<
typename Arc::Label,
const Fst<Arc> * >
116 ( unionindex_ + counter_, fst ) );
125 return new VectorFst<Arc> ( ReplaceFst<Arc> ( pairlabelfsts_,
126 ReplaceFstOptions<Arc> ( unionindex_, true ) ) );
VectorFst< Arc > * operator()()
void Add(Fst< Arc > const *fst)
Adds an fst to the list.
This class creates the Union of an arbitrarily large number of fsts. This implementation uses one RTN...
This class creates the Union of an arbitrarily large number of fsts. This implementation was suggeste...
MultiUnionReplace()
Constructor, initializes the head fst of the RTN.
void Add(boost::shared_ptr< Fst< Arc > const > fst)
Adds an fst to the list.
void Add(Fst< Arc > const *fst)
Also adds an fst, but takes a pointer as input. Note that we are using internally a list of shared_pt...
MultiUnionRational()
Empty Constructor.