Imported from https://github.com/neulab/xnmt