A finite state transducer. Each state is uniquely identified by a
label, which is typically a string name or an integer id. A state's
label is used to access and modify the state. Similarly, each arc is
uniquely identified by a label, which is used to access and modify the
arc.
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__
|
|
states(self)
Return an iterator that will generate the state label of each state
in this FST. |
source code
|
|
|
has_state(self,
label)
Return true if this FST contains a state with the given label. |
source code
|
|
|
|
|
|
|
incoming(self,
state)
Return an iterator that will generate the incoming transition arcs
for the given state. |
source code
|
|
|
outgoing(self,
state)
Return an iterator that will generate the outgoing transition arcs
for the given state. |
source code
|
|
|
is_final(self,
state)
Return true if the state with the given state label is final. |
source code
|
|
|
|
|
state_descr(self,
state)
Return the description for the given state, if it has one; or None,
otherwise. |
source code
|
|
|
arcs(self)
Return an iterator that will generate the arc label of each
transition arc in this FST. |
source code
|
|
|
src(self,
arc)
Return the state label of this transition arc's source state. |
source code
|
|
|
dst(self,
arc)
Return the state label of this transition arc's destination state. |
source code
|
|
|
in_string(self,
arc)
Return the given transition arc's input string, a (possibly empty)
tuple of input symbols. |
source code
|
|
|
out_string(self,
arc)
Return the given transition arc's output string, a (possibly empty)
tuple of output symbols. |
source code
|
|
|
arc_descr(self,
arc)
Return the description for the given transition arc, if it has one;
or None, otherwise. |
source code
|
|
|
arc_info(self,
arc)
Return a tuple (src, dst, in_string, out_string) for the given arc,
where: |
source code
|
|
|
is_sequential(self)
Return true if this FST is sequential. |
source code
|
|
|
is_subsequential(self)
Return true if this FST is subsequential. |
source code
|
|
|
add_state(self,
label=None,
is_final=True,
finalizing_string=( ) ,
descr=None)
Create a new state, and return its label. |
source code
|
|
|
|
|
set_final(self,
state,
is_final=True)
If is_final is true, then make the state with the given
label final; if is_final is false, then make the state
with the given label non-final. |
source code
|
|
|
set_finalizing_string(self,
state,
finalizing_string)
Set the given state's finalizing string. |
source code
|
|
|
set_descr(self,
state,
descr)
Set the given state's description string. |
source code
|
|
|
|
|
add_arc(self,
src,
dst,
in_string,
out_string,
label=None,
descr=None)
Create a new transition arc, and return its label. |
source code
|
|
|
del_arc(self,
label)
Delete the transition arc with the given label. |
source code
|
|
|
inverted(self)
Swap all in_string/out_string pairs. |
source code
|
|
|
reversed(self)
Reverse the direction of all transition arcs. |
source code
|
|
|
|
|
relabeled(self,
label=None,
relabel_states=True,
relabel_arcs=True)
Return a new FST that is identical to this FST, except that all state
and arc labels have been replaced with new labels. |
source code
|
|
|
_relabel_state_ids(self,
state,
ids)
A helper function for relabel() , which
decides which new label should be assigned to each state. |
source code
|
|
|
determinized(self,
label=None)
Return a new FST which defines the same mapping as this FST, but is
determinized. |
source code
|
|
|
_all_equal(self,
lst)
Return true if all elements in the list are equal |
source code
|
|
|
_common_prefix(self,
sequences)
Return the longest sequence that is a prefix of all of the given
sequences. |
source code
|
|
|
|
|
|
|
dotgraph(self)
Return an AT&T graphviz dot graph. |
source code
|
|
|
transduce_subsequential(self,
input,
step=True) |
source code
|
|
|
step_transduce_subsequential(self,
input,
step=True)
This is implemented as a generator, to make it easier to support
stepping. |
source code
|
|
|
|
|
step_transduce(self,
input,
step=True)
This is implemented as a generator, to make it easier to support
stepping. |
source code
|
|
|
_pick_label(self,
label,
typ,
used_labels)
Helper function for add_state and add_arc that chooses a
label for a new state or arc. |
source code
|
|
|
label
A label identifying this FST.
|
|
_initial_state
The label of the initial state, or None if this FST does
not have an initial state.
|
|
_incoming
A dictionary mapping state labels to lists of incoming transition arc
labels.
|
|
_outgoing
A dictionary mapping state labels to lists of outgoing transition arc
labels.
|
|
_is_final
A dictionary mapping state labels to boolean values, indicating
whether the state is final.
|
|
_finalizing_string
A dictionary mapping state labels of final states to output strings.
|
|
_state_descr
A dictionary mapping state labels to (optional) state descriptions.
|
|
_src
A dictionary mapping each transition arc label to the label of its
source state.
|
|
_dst
A dictionary mapping each transition arc label to the label of its
destination state.
|
|
_in_string
A dictionary mapping each transition arc label to its input string, a
(possibly empty) tuple of input symbols.
|
|
_out_string
A dictionary mapping each transition arc label to its output string,
a (possibly empty) tuple of input symbols.
|
|
_arc_descr
A dictionary mapping transition arc labels to (optional) arc
descriptions.
|