# Difficulty in understanding Hidden Markov Model for syntax parsing using Viterbi algorithm

I intend to apply Kevin Murphy's Hidden markov model (HMM) toolbox. I have a set of production rules(arbitrary) $A_0 \to AB [p=1]$, $A\to aC [p=1]$, $B\to bbC [p=0.5]$, $B\to b [p=0.5]$ where $A_0$ is the start symbol, A, B, C are the non terminals, and a and b are the terminals and the probabilities are put in brackets. The observation is {aabc}.

I do not know how to use the Viterbi parsing algorithm and cannot understand what all values in the parameters to use in the toolbox. Can anyone explain with a simple example how to use the program so as to select a maximum likelihood parse and how to train?

The objective is to classify a language or a text string. Any other example apart from language would also help. Primary question is how to feed in all these data in the toolbox so as to train the HMM and how to use it for the task since evrything in it uses rand function, how do I customize it?

1. Number of states Q=4 ? ($A_0$, A, B, C)
2. Number of observation symbols of length T=4; number of sequences nex=1?

yeah ok. i've just done some work on it. i've managed to make it done even if i haven't got all math beyound.

### EDIT:

this is some usefull resoruces:

i've done some gesture recognition so my resources are biased for this specific application but you could find a sequence classification frameworks behind it.

1. some good slides
2. some other good slides with good example and MATLAB code in the last ones
3. a good link with MATLAB/OCTAVE code for gesture recognition
4. another good link with clear, easy-to-understan, with all source code in c#. in this, also, there is as an example a basic sequence classifier and there it shows some train values and the log probability for some new sequences.

to let my work done i've grabbed the initial values (the alphabet and number of hidden states == the size of the matrixes) from this and then i've played with them.

i've also rewritten the little part of kevin murphy matlab code in c++ using armadillo library for linear algebra (matrix) calculi. if you are interested in it just let me know.

hope it helps.

• Thank you and would be highly obliged if you could pass on the modified script which you have written.
– chk
Commented Mar 28, 2012 at 17:05
• One thing is still unclear is how to figure out the observation symbol probability for gestures?
– chk
Commented Mar 28, 2012 at 17:12
• the problem is that the coordinates of gesture must to be labelled. i used a kmeans approach, using custom centroids (a grid) link in creative distraction explain the method i've used Commented Mar 28, 2012 at 17:39
• Another thing,in the second link which has the code,why the number of transmat for class 0 is 3*3 and number of observations =16 and transmat for class1 is a 2*2 matrix but number of observation states=16.This is puzzling me.Could you kindly throw some light?thanx
– chk
Commented Mar 28, 2012 at 18:20
• i think you are confusing the number of observations with the length of alphabet with the obs are composed Commented Mar 29, 2012 at 10:32