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::StringPaths`

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, whether or not epsilon labels should be ignored when printing the string, 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.StringPaths`

Pynini wraps `fst::script::StringPathsClass`

with the Python class
`StringPaths`

. 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: r2 - 2017-07-27 - KyleGorman

Copyright © 2008-2022 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