Handwritten word recognition using message passing in hidden markov models