Discriminative learning for hidden Markov models