title: Viterbi algorithm in java
body: <p>I'm doing the coursera NLP course and the first programming assignment is to build a Viterbi decoder. I think I'm really close to finishing it but there is some elusive bug which I cannot seem to be able to trace. Here is my code: </p>
  
  <p><a href="http://pastie.org/private/ksmbns3gjctedu1zxrehw" rel="noreferrer">http://pastie.org/private/ksmbns3gjctedu1zxrehw</a></p>
  
  <p><a href="http://pastie.org/private/ssv6tc8dwnamn2qegdvww" rel="noreferrer">http://pastie.org/private/ssv6tc8dwnamn2qegdvww</a></p>
  
  <p>So far I've debugged the "teaching" related functions so I can say that the parameters for the algorithms are being correctly estimated. Of particular interest is the viterbi() and findW() methods. The definition of the algorithm I'm using can be found here: <a href="http://www.cs.columbia.edu/~mcollins/hmms-spring2013.pdf" rel="noreferrer">http://www.cs.columbia.edu/~mcollins/hmms-spring2013.pdf</a> on page 18. </p>
  
  <p>One thing which I'm having hard time wrapping my head around is how am I supposed to update the backpointers for the special cases when K = {1, 2} (in my case this is 0 and 1, since I'm zero-indexing my array) respectively the parameters I'm using in those cases are q({TAGSET} | *, *) and q ({TAGSET} | *, {TAGSET}). </p>
  
  <p>Hints rather than spoon-fed answers will also be highly appreciated!</p>