Package fsa_recognizer :: Module read_fst_file :: Class DotFstCompiler
[hide private]
[frames] | no frames]

Class DotFstCompiler

source code

 object --+    
          |    
FstCompiler --+
              |
             DotFstCompiler

Code for compiling an ATT graphviz ("dot") representation of an FST into a Python FST rep.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
initialize_reader(self)
This function zeroes out all the records kept during the reading of a fst file so that the same compiler can be used on a new file safely.
source code
dictionary of dictionary of dictionaries
read_file(self, file)
Open dot file file and return raw_dic, a dictionary representation of the FST represented there.
source code
 
cmp_item(self, item1, item2)
Items are pairs of state names and transition fns.
source code
None
classify_node(self, node_name, att_dic, node_dic)
Determine whether node_name is a start state and whether it is a final state.
source code
 
classify_link(self, src_node_name, tgt_node_name, att_dic, node_dic)
Turn the label in a dot file string rep into a series of transitions in the Python FST we are building.
source code
 
is_start_node(self, att_dic) source code
 
is_final_node(self, att_dic) source code
dictionary
process_atts(self, att_string)
Turn a string rep of node or transition attributes from a dot file into a dictionary with keys = to attributes.
source code
 
find_graph_type(self, lines) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

initialize_reader(self)

source code 

This function zeroes out all the records kept during the reading of a fst file so that the same compiler can be used on a new file safely. Shd be called by read_file.

Overrides: FstCompiler.initialize_reader

read_file(self, file)

source code 

Open dot file file and return raw_dic, a dictionary representation of the FST represented there.

We retain the state names in the dot file, but we assume they are string reps of integers, an assumption not b uilt into dot-files.

See interface documentation for Class FstCompiler method read_file. This method respects that interface.

Parameters:
  • file - file containing dot representation of an FST.
Returns: dictionary of dictionary of dictionaries
Overrides: FstCompiler.read_file

cmp_item(self, item1, item2)

source code 

Items are pairs of state names and transition fns.

We assume state names are string reps of ints and that the starting state has been named '0'.

classify_node(self, node_name, att_dic, node_dic)

source code 

Determine whether node_name is a start state and whether it is a final state. Update node_dic with this info.

Assume node names are string reps of integers, but map them to int keys in node_dic

Parameters:
  • node_name - string
  • att_dic - dictionary (of attribute value pairs)
  • node_dic - dictionary (the FST we are updating)
Returns: None

classify_link(self, src_node_name, tgt_node_name, att_dic, node_dic)

source code 

Turn the label in a dot file string rep into a series of transitions in the Python FST we are building.

src_node_name is the name of the state whose transition function we will be updating.

Assume node names are string reps of integers, but map them to int keys in node-dic

Parameters:
  • src_node_name - string
  • tgt_node_name - string
  • att_dic - dic represention of att value pairs attached to the transition from src to tgt.
  • node_dic - the dictionary representation of the FST to be updated

process_atts(self, att_string)

source code 

Turn a string rep of node or transition attributes from a dot file into a dictionary with keys = to attributes.

Parameters:
  • att_string - string
Returns: dictionary