Public Types | Public Member Functions | Friends

fst::ReplaceFst< A, T, C > Class Template Reference

Recursively replaces arcs in the root Fst with other Fsts. This version is a delayed Fst. More...

#include <fst/replace.h>

Inherits ImplToFst< ReplaceFstImpl< A, T, C > >.

Collaboration diagram for fst::ReplaceFst< A, T, C >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef A Arc
typedef A::Label Label
typedef A::Weight Weight
typedef A::StateId StateId
typedef T StateTable
typedef C Store
typedef C::State State
typedef CacheBaseImpl< State, C > CImpl
typedef ReplaceFstImpl< A, T, C > Impl

Public Member Functions

 ReplaceFst (const std::vector< std::pair< Label, const Fst< A > * >> &fst_array, Label root)
 ReplaceFst (const std::vector< std::pair< Label, const Fst< A > * >> &fst_array, const ReplaceFstOptions< A, T, C > &opts)
 ReplaceFst (const ReplaceFst< A, T, C > &fst, bool safe=false)
 See Fst<>::Copy() for doc.
ReplaceFst< A, T, C > * Copy (bool safe=false) const override
 Get a copy of this ReplaceFst. See Fst<>::Copy() for further doc.
void InitStateIterator (StateIteratorData< A > *data) const override
void InitArcIterator (StateId s, ArcIteratorData< A > *data) const override
MatcherBase< A > * InitMatcher (MatchType match_type) const override
bool CyclicDependencies () const
const StateTableGetStateTable () const
const Fst< A > & GetFst (Label nonterminal) const

Friends

class ArcIterator< ReplaceFst< A, T, C > >
class StateIterator< ReplaceFst< A, T, C > >
class ReplaceFstMatcher< A, T, C >

Detailed Description

template<class A, class T, class C>
class fst::ReplaceFst< A, T, C >

Recursively replaces arcs in the root Fst with other Fsts. This version is a delayed Fst.

ReplaceFst supports dynamic replacement of arcs in one Fst with another Fst. This replacement is recursive. ReplaceFst can be used to support a variety of delayed constructions such as recursive transition networks, union, or closure. It is constructed with an array of Fst(s). One Fst represents the root (or topology) machine. The root Fst refers to other Fsts by recursively replacing arcs labeled as non-terminals with the matching non-terminal Fst. Currently the ReplaceFst uses the output symbols of the arcs to determine whether the arc is a non-terminal arc or not. A non-terminal can be any label that is not a non-zero terminal label in the output alphabet.

Note that the constructor uses a vector of std::pair<>. These correspond to the tuple of non-terminal Label and corresponding Fst. For example to implement the closure operation we need 2 Fsts. The first root Fst is a single Arc on the start State that self loops, it references the particular machine for which we are performing the closure operation.

The ReplaceFst class supports an optionally caching arc iterator: ArcIterator< ReplaceFst> The ReplaceFst need to be built such that it is known to be ilabel or olabel sorted (see usage below).

Observe that Matcher<Fst> will use the optionally caching arc iterator when available (Fst is ilabel sorted and matching on the input, or Fst is olabel sorted and matching on the output). In order to obtain the most efficient behaviour, it is recommended to set call_label_type to REPLACE_LABEL_INPUT or REPLACE_LABEL_BOTH and return_label_type to REPLACE_LABEL_OUTPUT or REPLACE_LABEL_NEITHER (this means that the call arc does not have epsilon on the input side and the return arc has epsilon on the input side) and matching on the input side.

This class attaches interface to implementation and handles reference counting, delegating most methods to ImplToFst.

Definition at line 1070 of file replace.h.


Member Typedef Documentation

template<class A, class T, class C>
typedef A fst::ReplaceFst< A, T, C >::Arc

Reimplemented from fst::ImplToFst< ReplaceFstImpl< A, T, C > >.

Definition at line 1076 of file replace.h.

template<class A, class T, class C>
typedef CacheBaseImpl<State, C> fst::ReplaceFst< A, T, C >::CImpl

Definition at line 1083 of file replace.h.

template<class A, class T, class C>
typedef ReplaceFstImpl<A, T, C> fst::ReplaceFst< A, T, C >::Impl

Definition at line 1084 of file replace.h.

template<class A, class T, class C>
typedef A::Label fst::ReplaceFst< A, T, C >::Label

Definition at line 1077 of file replace.h.

template<class A, class T, class C>
typedef C::State fst::ReplaceFst< A, T, C >::State

Definition at line 1082 of file replace.h.

template<class A, class T, class C>
typedef A::StateId fst::ReplaceFst< A, T, C >::StateId

Reimplemented from fst::ImplToFst< ReplaceFstImpl< A, T, C > >.

Definition at line 1079 of file replace.h.

template<class A, class T, class C>
typedef T fst::ReplaceFst< A, T, C >::StateTable

Definition at line 1080 of file replace.h.

template<class A, class T, class C>
typedef C fst::ReplaceFst< A, T, C >::Store

Definition at line 1081 of file replace.h.

template<class A, class T, class C>
typedef A::Weight fst::ReplaceFst< A, T, C >::Weight

Reimplemented from fst::ImplToFst< ReplaceFstImpl< A, T, C > >.

Definition at line 1078 of file replace.h.


Constructor & Destructor Documentation

template<class A, class T, class C>
fst::ReplaceFst< A, T, C >::ReplaceFst ( const std::vector< std::pair< Label, const Fst< A > * >> &  fst_array,
Label  root 
) [inline]

Definition at line 1088 of file replace.h.

template<class A, class T, class C>
fst::ReplaceFst< A, T, C >::ReplaceFst ( const std::vector< std::pair< Label, const Fst< A > * >> &  fst_array,
const ReplaceFstOptions< A, T, C > &  opts 
) [inline]

Definition at line 1093 of file replace.h.

template<class A, class T, class C>
fst::ReplaceFst< A, T, C >::ReplaceFst ( const ReplaceFst< A, T, C > &  fst,
bool  safe = false 
) [inline]

See Fst<>::Copy() for doc.

Definition at line 1098 of file replace.h.


Member Function Documentation

template<class A, class T, class C>
ReplaceFst<A, T, C>* fst::ReplaceFst< A, T, C >::Copy ( bool  safe = false  )  const [inline, override, virtual]

Get a copy of this ReplaceFst. See Fst<>::Copy() for further doc.

Implements fst::Fst< typename ReplaceFstImpl< A, T, C >::Arc >.

Definition at line 1102 of file replace.h.

template<class A, class T, class C>
bool fst::ReplaceFst< A, T, C >::CyclicDependencies (  )  const [inline]

Definition at line 1123 of file replace.h.

template<class A, class T, class C>
const Fst<A>& fst::ReplaceFst< A, T, C >::GetFst ( Label  nonterminal  )  const [inline]

Definition at line 1129 of file replace.h.

template<class A, class T, class C>
const StateTable& fst::ReplaceFst< A, T, C >::GetStateTable (  )  const [inline]

Definition at line 1125 of file replace.h.

template<class A, class T, class C>
void fst::ReplaceFst< A, T, C >::InitArcIterator ( StateId  s,
ArcIteratorData< A > *  data 
) const [inline, override]

Definition at line 1108 of file replace.h.

template<class A, class T, class C>
MatcherBase<A>* fst::ReplaceFst< A, T, C >::InitMatcher ( MatchType  match_type  )  const [inline, override, virtual]

For generic matcher construction; not normally called directly by users.

Reimplemented from fst::Fst< typename ReplaceFstImpl< A, T, C >::Arc >.

Definition at line 1112 of file replace.h.

template<class A, class T , class C >
void fst::ReplaceFst< A, T, C >::InitStateIterator ( StateIteratorData< A > *  data  )  const [inline, override]

Definition at line 1537 of file replace.h.


Friends And Related Function Documentation

template<class A, class T, class C>
friend class ArcIterator< ReplaceFst< A, T, C > > [friend]

Definition at line 1072 of file replace.h.

template<class A, class T, class C>
friend class ReplaceFstMatcher< A, T, C > [friend]

Definition at line 1074 of file replace.h.

template<class A, class T, class C>
friend class StateIterator< ReplaceFst< A, T, C > > [friend]

Definition at line 1073 of file replace.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines