Minimum-risk training for semi-Markov conditional random fields with application to handwritten Chinese/Japanese text recognition