Package viterbi
[hide private]
[frames] | no frames]

Package viterbi

source code

Code implementing the viterbi best paths algorithm for HMMs.

Usage is as follows

To use Machine 1 (coin tossing machine):

>>> decode_line('httt',A1, B1, states1, start1)

The variables A1, B1, states1, and start1 are all globals vars defined in viterbi.viterbi_search.

To use Machine 2 (Jurafsky and Martin word decoder):

>>> X = decode_line(Stringseq,A2, B2, states2, start2, False)

The variables Stringseq, A2, B2, states2, and start2 are also defined in viterbi.viterbi_search. To print the Viterbi table for this decoding, run:

>>> print_viterbi_table(X[0],Stringseq,states2, start2,9)

X here is the tuple returned by decode_line, the first member of which is the viterbi table. "9" is the precision level for printing floats. This is the precision level needed to reproduce Figure 7.10.

To use Machine 3 (Eisner diary ice cream machine):

>>> decode_line('313',A3, B3, states3, start3)

This runs with Machine 3, the ice cream/weather machine of Chapter 6, Jurafsky & Martin, with the input diagrammed in Fig 6.10.

Submodules [hide private]