Exemplo n.º 1
0
    def __init__(self, name, source_lang, target_lang):
        Engine.__init__(self, name, source_lang, target_lang)

        # Phrase-based specific models
        self.moses = Moses(os.path.join(self.models_path, 'decoder'),
                           self.source_lang, self.target_lang)
        self.vocabulary_path = self.moses.vb.model
Exemplo n.º 2
0
    def __init__(self, name, source_lang, target_lang, bpe_symbols, max_vocab_size=None, vocab_pruning_threshold=None):
        Engine.__init__(self, name, source_lang, target_lang)

        self._bleu_script = os.path.join(PYOPT_DIR, 'mmt-bleu.perl')

        decoder_path = os.path.join(self.models_path, 'decoder')

        # Neural specific models
        model_name = 'model.%s__%s' % (source_lang, target_lang)

        memory_path = os.path.join(decoder_path, 'memory')
        decoder_model = os.path.join(decoder_path, model_name)

        self.memory = TranslationMemory(memory_path, self.source_lang, self.target_lang)
        self.nmt_preprocessor = NMTPreprocessor(self.source_lang, self.target_lang,
                                                bpe_symbols=bpe_symbols, max_vocab_size=max_vocab_size,
                                                vocab_pruning_threshold=vocab_pruning_threshold)
        self.decoder = NMTDecoder(decoder_model, self.source_lang, self.target_lang)