rxn.onmt_models.translation.rxn_translation
- rxn.onmt_models.translation.rxn_translation(src_file, tgt_file, pred_file, model, n_best, beam_size, batch_size, gpu, max_length=300, as_external_command=False)[source]
Do a forward or retro translation.
This function takes care of tokenizing/detokenizing the input. In principle, by adapting the “invalid” placeholder, this could also work when input/output are full reactions.
Note: no check is made that the source is canonical.
- Parameters
src_file (
Union
[str
,PathLike
]) – source file (tokenized or detokenized).tgt_file (
Union
[str
,PathLike
,None
]) – ground truth file (tokenized or detokenized), not mandatory.pred_file (
Union
[str
,PathLike
]) – file where to save the predictions.model (
Union
[str
,PathLike
]) – model to do the translationn_best (
int
) – number of predictions to make for each input.beam_size (
int
) – beam size.batch_size (
int
) – batch size.gpu (
bool
) – whether to use the GPU.max_length (
int
, default:300
) – maximum sequence length.as_external_command (
bool
, default:False
) – runs the onmt command instead of Python code.
- Return type
None