HFST: Transducer Core Extension API

This document deals with the datatypes related to core transducer manipulation. This layer is meant to support

  1. the layers above the HfstAPITransducerLayer to make the necessary extensions to its functionality, and
  2. some user-defined functions that traverse through transducers.

The current layer does not mean to be restrictive when implementing HfstAPITransducerLayer. The implementation of that layer has unrestricted access to much larger set of package-specific data types and methods. It would be too difficult to try to specify a graph-manipulation layer that would capture all the possibilities.

Datatypes for States and Transitions


Name of the type Comment
State A state in a transducer.
Transition A transition between two states.
TransitionIterator A transition iterator over all transitions from a state.


Defining states:

Type Function Comment
State create_state (TransducerHandle t) Create a state in transducer t.
State set_final_state (State s, TransducerHandle t, float w=0 ) Set the state s in transducer t as final with weight w.

Defining transitions:

Type Function Comment
Transition define_transition (TransducerHandle t, State orig, KeyPair p, State target, float w=0 ) Define a transition leaving from state orig in transducer t with key pair p, target state target, and weight w.

Using states:

Type Function Comment
State get_initial_state (TransducerHandle t) Get initial state from transducer t.
bool is_final_state (State s, TransducerHandle t) Whether state s in transducer t is final.
float get_final_weight (State s, TransducerHandle t) Get the weight of state s in transducer t.

Using transitions:

Type Function Comment
KeyPair get_transition_keypair (Transition tr) Get the key pair of transition t.
State get_transition_to (Transition tr) Get the goal state of transition t.
float get_transition_weight (Transition tr) Get the weight w of transition t.

Iterators over transitions:

Type Function Comment
TransitionIterator begin_ti (TransducerHandle t, State s) A transition iterator over transitions in state s in transducer t.
- ti++ Move transition iterator ti to represent the next transition.
bool is_end_ti (TransitionIterator ti) Whether transition iterator ti has passed the last transition.
Transition get_ti_transition (TransitionIterator ti) Get the transition represented by the transition iterator ti.

Not implemented (yet):

Iterators over states (not necessarily visible in the API):

Type Function Comment
StateIterator begin_si (TransducerHandle t) A transition iterator over states in transducer t.
- si++ Move state iterator si to represent the next state.
bool is_end_si (StateIterator si) Whether state iterator si has passed the last state.
State get_si_state (StateIterator si) Get the state represented by the state iterator si.

Type Function Comment
State set_marked_state (State s) Set the state s as marked.
State unset_marked_state (State s) Unset the state s as marked.
bool is_marked (State s) Whether state s has been marked.
size_t size_ti (TransitionIterator ti) Size of the transition iterator ti.

-- KristerLinden - 11 Oct 2008

Topic revision: r11 - 2009-09-30 - ErikAxelson
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback