#include <grammar-context-fst.h>
Public Types | |
typedef StdArc | Arc |
typedef StdArc::StateId | StateId |
typedef StdArc::Weight | Weight |
typedef StdArc::Label | Label |
Public Types inherited from DeterministicOnDemandFst< StdArc > | |
typedef StdArc ::StateId | StateId |
typedef StdArc ::Weight | Weight |
typedef StdArc ::Label | Label |
Public Member Functions | |
InverseLeftBiphoneContextFst (Label nonterm_phones_offset, const std::vector< int32 > &phones, const std::vector< int32 > &disambig_syms) | |
Constructor. More... | |
virtual StateId | Start () |
Here is a note on the state space of InverseLeftBiphoneContextFst; see Special symbols in C.fst which has some documentation on this. More... | |
virtual Weight | Final (StateId s) |
virtual bool | GetArc (StateId s, Label ilabel, Arc *arc) |
Note: ilabel must not be epsilon. More... | |
~InverseLeftBiphoneContextFst () | |
const std::vector< std::vector< int32 > > & | IlabelInfo () const |
void | SwapIlabelInfo (std::vector< std::vector< int32 > > *vec) |
Public Member Functions inherited from DeterministicOnDemandFst< StdArc > | |
virtual Weight | Final (StateId s)=0 |
virtual bool | GetArc (StateId s, Label ilabel, StdArc *oarc)=0 |
Note: ilabel must not be epsilon. More... | |
virtual | ~DeterministicOnDemandFst () |
Private Types | |
typedef unordered_map< std::vector< int32 >, Label, kaldi::VectorHasher< int32 > > | VectorToLabelMap |
Private Member Functions | |
int32 | GetPhoneSymbolFor (enum NonterminalValues n) |
Label | FindLabel (const std::vector< int32 > &label_info) |
Finds the label index corresponding to this context-window of phones (likely of width context_width_). More... | |
Private Attributes | |
int32 | nonterm_phones_offset_ |
kaldi::ConstIntegerSet< Label > | phone_syms_ |
kaldi::ConstIntegerSet< Label > | disambig_syms_ |
VectorToLabelMap | ilabel_map_ |
std::vector< std::vector< int32 > > | ilabel_info_ |
Definition at line 146 of file grammar-context-fst.h.
Definition at line 148 of file grammar-context-fst.h.
typedef StdArc::Label Label |
Definition at line 151 of file grammar-context-fst.h.
typedef StdArc::StateId StateId |
Definition at line 149 of file grammar-context-fst.h.
|
private |
Definition at line 248 of file grammar-context-fst.h.
typedef StdArc::Weight Weight |
Definition at line 150 of file grammar-context-fst.h.
InverseLeftBiphoneContextFst | ( | Label | nonterm_phones_offset, |
const std::vector< int32 > & | phones, | ||
const std::vector< int32 > & | disambig_syms | ||
) |
Constructor.
This does not take the arguments 'context_width' or 'central_position' because they are assumed to be (2, 1) meaning a system with left-biphone context; and there is no subsequential symbol because it is not needed in systems without right context.
[in] | nonterm_phones_offset | The integer id of the symbol #nonterm_bos in the phones.txt file. You can just set this to a large value (like 1 million) if you are not actually using nonterminals (e.g. for testing purposes). |
[in] | phones | List of integer ids of phones, as you would see in phones.txt |
[in] | disambig_syms | List of integer ids of disambiguation symbols, e.g. the ids of #0, #1, #2 in phones.txt |
See The ContextFst object for more details.
Definition at line 27 of file grammar-context-fst.cc.
References ConstIntegerSet< I >::empty(), InverseLeftBiphoneContextFst::FindLabel(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, KALDI_WARN, InverseLeftBiphoneContextFst::phone_syms_, and kaldi::SortAndUniq().
|
inline |
Definition at line 218 of file grammar-context-fst.h.
|
virtual |
Definition at line 81 of file grammar-context-fst.cc.
References ConstIntegerSet< I >::count(), InverseLeftBiphoneContextFst::GetPhoneSymbolFor(), fst::kNontermEnd, and InverseLeftBiphoneContextFst::phone_syms_.
Referenced by InverseLeftBiphoneContextFst::Start().
|
private |
Finds the label index corresponding to this context-window of phones (likely of width context_width_).
Inserts it into the ilabel_info_/ilabel_map_ tables if necessary.
Definition at line 181 of file grammar-context-fst.cc.
References InverseLeftBiphoneContextFst::ilabel_info_, and InverseLeftBiphoneContextFst::ilabel_map_.
Referenced by InverseLeftBiphoneContextFst::GetArc(), InverseLeftBiphoneContextFst::GetPhoneSymbolFor(), and InverseLeftBiphoneContextFst::InverseLeftBiphoneContextFst().
Note: ilabel must not be epsilon.
Definition at line 89 of file grammar-context-fst.cc.
References ConstIntegerSet< I >::count(), InverseLeftBiphoneContextFst::disambig_syms_, InverseLeftBiphoneContextFst::FindLabel(), InverseLeftBiphoneContextFst::GetPhoneSymbolFor(), KALDI_ASSERT, KALDI_ERR, fst::kNontermBegin, fst::kNontermBos, fst::kNontermEnd, fst::kNontermReenter, fst::kNontermUserDefined, and InverseLeftBiphoneContextFst::phone_syms_.
Referenced by InverseLeftBiphoneContextFst::Start().
|
inlineprivate |
Definition at line 234 of file grammar-context-fst.h.
References InverseLeftBiphoneContextFst::FindLabel(), rnnlm::n, and InverseLeftBiphoneContextFst::nonterm_phones_offset_.
Referenced by InverseLeftBiphoneContextFst::Final(), and InverseLeftBiphoneContextFst::GetArc().
|
inline |
Definition at line 224 of file grammar-context-fst.h.
References InverseLeftBiphoneContextFst::ilabel_info_.
|
inlinevirtual |
Here is a note on the state space of InverseLeftBiphoneContextFst; see Special symbols in C.fst which has some documentation on this.
The state space uses the same numbering as phones.txt.
State 0 means the beginning-of-sequence state, where there is no left context.
For each phone p in the list 'phones' passed to the constructor (i.e. in the set passed to the constructor), the state 'p' corresponds to a left-context of that phone.
If p is equal to nonterm_phones_offset_ + kNontermBegin (i.e. the integer form of `#nonterm_begin`), then this is the state we transition to when we see that symbol starting from left-context==0 (no context). The transition to this special state will have epsilon on the output. (talking here about inv(C), not C, so input/output are reversed). The state is nonfinal and when we see a regular phone p1 or #nonterm_bos, instead of outputting that phone in context, we output the pair (#nonterm_begin,p1) or (#nonterm_begin,#nonterm_bos). This state is not final.
If p is equal to nonterm_phones_offset_ + kNontermUserDefined, then this is the state we transition to when we see any user-defined nonterminal. Transitions to this special state have olabels of the form (#nonterm:foo,p1) where p1 is the preceding context (with #nonterm_begin if that context was 0); transitions out of it have olabels of the form (#nonterm_reenter,p2), where p2 is the phone on the ilabel of that transition. Again: talking about inv(C). This state is not final.
If p is equal to nonterm_phones_offset_ + kNontermEnd, then this is the state we transition to when we see the ilabel #nonterm_end. The olabels on the transitions to it (talking here about inv(C), so ilabels and olabels are reversed) are of the form (#nonterm_end, p1) where p1 corresponds to the context we were in. This state is final.
Implements DeterministicOnDemandFst< StdArc >.
Definition at line 211 of file grammar-context-fst.h.
References InverseLeftBiphoneContextFst::Final(), and InverseLeftBiphoneContextFst::GetArc().
|
inline |
Definition at line 230 of file grammar-context-fst.h.
References InverseLeftBiphoneContextFst::ilabel_info_.
Referenced by fst::ComposeContextLeftBiphone().
|
private |
Definition at line 264 of file grammar-context-fst.h.
Referenced by InverseLeftBiphoneContextFst::GetArc().
|
private |
Definition at line 280 of file grammar-context-fst.h.
Referenced by InverseLeftBiphoneContextFst::FindLabel(), InverseLeftBiphoneContextFst::IlabelInfo(), and InverseLeftBiphoneContextFst::SwapIlabelInfo().
|
private |
Definition at line 272 of file grammar-context-fst.h.
Referenced by InverseLeftBiphoneContextFst::FindLabel().
|
private |
Definition at line 252 of file grammar-context-fst.h.
Referenced by InverseLeftBiphoneContextFst::GetPhoneSymbolFor().
|
private |
Definition at line 255 of file grammar-context-fst.h.
Referenced by InverseLeftBiphoneContextFst::Final(), InverseLeftBiphoneContextFst::GetArc(), and InverseLeftBiphoneContextFst::InverseLeftBiphoneContextFst().