---+ <nop>OpenFst Conventions The <nop>OpenFst Libary has various conventions and assumptions about its objects and coding style. ---++ Object Conventions 1. The =StateIds= of an FST are dense integers, numbered from 0 to =NumStates()= - 1. 1. A =StateIterator= returns =StateIds= in numerical order. 1. A user may not request info about a =StateId= *s* from an FST unless the FST has already returned a =StateId= *t* ≥ *s* (e.g. from =Start()=, =NumStates()=, =StateIterator=, or =ArcIterator->Value().nextstate=). 1. The empty machine (no states) has start state =kNoStateId=; a non-empty machine (has states) has a valid start state. 1. A =Label= is a non-negative integer except =kNoLabel= (or library internals). The label =0= is reserved for [[FstGlossary#EpsilonDef][epsilon]]. 1. A =Weight= satisfies the properties described [[FstWeightRequirements][here]]. 1. A =StateIterator= is invalidated if the number of states is modified. 1. An =ArcIterator= for a state is invalidated by any mutation of the arcs at that state. 1. A =MutableArcIterator= is invalidated by any mutation of the arcs at that state other than by the iterator itself. 1. A =Matcher= is invalidated by any mutation of an FST. 1. A reference/pointer to an arc is invalidated at the next operation on an FST, state iterator, arc iterator, or matcher. 1. State iterators, arc iterators and matchers should be destroyed prior to destroying their component FSTs. 1. All FST classes F implement a copy constructor =F(const &F)=. 1. The copy constructor and =Copy()= method of an FST have constant time and space complexity (shallow copy) unless otherwise noted. ---++ Coding Conventions ---+++ FST Application Code: 1. Your code should rarely use =int= or =float= when referring to FST components. Use: * =StateId= for state Ids and number of states. * =Label= for labels. * =size_t= for other array lengths. * =Weight= for weights. ---+++ New FST classes: 1. All FST classes will implement working versions of all pure virtual member functions; writing dummy or error-raising versions is not permitted. 2. If class =C= is templated on an Arc, then =C::Arc= will give that type.
This topic: FST
>
WebHome
>
FstConventions
Topic revision: r17 - 2018-01-10 - KyleGorman
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback