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

Source Code for Package viterbi

 1  """ 
 2  Code implementing the viterbi best paths algorithm 
 3  for HMMs. 
 4   
 5  Usage is as follows 
 6   
 7  To use Machine 1 (coin tossing machine): 
 8   
 9    >>> decode_line('httt',A1, B1, states1, start1) 
10   
11  The variables C{A1}, C{B1}, C{states1}, and C{start1} 
12  are all globals vars defined in L{viterbi.viterbi_search}. 
13   
14  To use Machine 2 (Jurafsky and Martin word decoder): 
15   
16    >>> X = decode_line(Stringseq,A2, B2, states2, start2, False) 
17   
18  The variables C{Stringseq}, C{A2}, C{B2}, C{states2}, and C{start2} 
19  are also defined in L{viterbi.viterbi_search}. 
20  To print the Viterbi table for this decoding, run: 
21   
22    >>> print_viterbi_table(X[0],Stringseq,states2, start2,9) 
23   
24  C{X} here is the tuple returned by C{decode_line}, the first member of which 
25  is the viterbi table. "9" is the precision level for printing 
26  floats. This is the precision level needed to reproduce 
27  U{Figure 7.10<http://www-rohan.sdsu.edu/~gawron/compling/chap7/fig07.10.pdf>}. 
28   
29  To use Machine 3 (Eisner diary ice cream machine): 
30   
31     >>> decode_line('313',A3, B3, states3, start3) 
32   
33  This runs with Machine 3, the ice cream/weather machine of 
34  Chapter 6, Jurafsky & Martin, with the input diagrammed 
35  in Fig 6.10.   
36  """ 
37