rxn.onmt_utils.internal_translation_utils.RawTranslator
- class rxn.onmt_utils.internal_translation_utils.RawTranslator(opt)[source]
Bases:
objectTranslator class that is very coupled to the internal OpenNMT implementation.
- Parameters
opt (
Namespace) –
Methods
__init__(opt)- param opt
translate_sentences_with_onmt(sentences, ...)Do the translation (in tokenized format) with OpenNMT.
translate_with_onmt(opt)Do the translation (in tokenized format) with OpenNMT.
- translate_sentences_with_onmt(sentences, **opt_updated_kwargs)[source]
Do the translation (in tokenized format) with OpenNMT.
- Parameters
sentences (
Iterable[str]) – sentences to translateopt_updated_kwargs (
Any) – values to update in the “opt” of the translator. The translator is not instantiated again from those values, therefore this only affects values that are used for translation, such as n_best.
- Return type
Iterator[List[TranslationResult]]
- translate_with_onmt(opt)[source]
Do the translation (in tokenized format) with OpenNMT.
- Parameters
opt – args given to the main script
- Return type
Iterator[List[TranslationResult]]- Returns
Generator of TranslationResults; they will be yielded in chunks of size opt.shard_size.