FST Conventions
The FST Libary has various conventions and assumptions about its objects and coding style.
Object Conventions
- The
StateIds
of an FST are dense, numbered from 0 to NumStates()
- 1.
- A
StateIterator
returns StateIds
in numerical order.
- 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
).
- The empty machine has start state
kNoState
.
-
Labels
are non-negative except kNoLabel
(or library internals).
- State iterators are invalidated if the number of states is modified.
- Arc iterators are invalidated if the number of states or arcs is modified.
- A reference/pointer to an arc is invalidated at the next Fst, state or arc iterator operation.
- State and arc iterators should be destroyed prior to destroying their component FSTs.
- All Fst classes F implement a copy constructor
F(const &F)
.
- The copy constructor and
Copy()
are constant time and space operations (typically reference-counted shallow copies).
Coding Conventions
FST Application Code:
- 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:
- All Fst classes will implement working versions of all pure virtual member functions; writing dummy or error-raising versions not allowed.
- If class
C
is templated on an Arc, then C::Arc
will give that type.
--
CyrilAllauzen - 21 Nov 2006