This describes classes for iterating over paths in an FST.

`fst::PathIterator`

This template class provides a basic iterator over paths. It is constructed from
a `const Fst`

and an optional argument that specifies whether or not the
FST should be checked for acyclicity during construction.

The `ILabels()`

and `OLabels()`

methods return vectors of input and output
labels (respectively) of the current path, and the `Weight()`

method returns the
weight of the current path.

This iterator:

- is advanced using the
`Next()`

method, - is exhausted once the
`Done()`

returns`true`

, - is reset using the
`Reset()`

method, and - signals an error using the
`Error()`

method.

The acyclity check should only be disabled when the caller can ensure finite iteration (e.g., by knowing the FST is acyclic, or limiting the number of iterated paths).

`fst::StringPathIterator`

This template class is a thin wrapper around `fst::PathIterator`

which adds
`IString()`

and `OString()`

methods returning input and output strings. These
methods use the same string printing methods as `fst::PrintString`

and the
printing mode is controlled by the enum `fst::StringTokenType`

(see here for more information).

At construction time, users specify printing modes and/or symbol tables for the input and output sides of the FST, and whether or not the FST should be checked for acyclity.

This iterator:

- is advanced using the
`Next()`

method, - is exhausted once the
`Done()`

returns`true`

, - is reset using the
`Reset()`

method, and - signals an error using the
`Error()`

method.

The acyclity check should only be disabled when the caller can ensure finite iteration (e.g., by knowing the FST is acyclic, or limiting the number of iterated paths).

`pynini.StringPathIterator`

Pynini wraps `fst::script::StringPathIteratorClass`

with the Python class `StringPathIterator`

. As in C++, this object can be constructed directly from an FST argument, or it can be constructed using the `paths()`

method of an (acyclic)
`pynini.Fst`

instance.

Both construction methods take token types for both input- and output sides; for
the `SYMBOL`

token type, simply provide a `pynini.SymbolTable`

argument.

This class provides the normal iterator methods (`next()`

, `done()`

, `reset()`

,
and `error()`

).

Topic revision: r3 - 2018-06-29 - KyleGorman

Copyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback