Discriminative training and variational decoding in machine translation via novel algorithms for weighted hypergraphs