Beispiel #1
0
 def get_settings(self):
     """
     Initialize and customize settings.
     """
     translation_settings = TranslationSettings()
     translation_settings.input = open('../../en-de/in')
     translation_settings.output = open('../../en-de/out', 'w')
     translation_settings.models = ["model.npz"]
     translation_settings.beam_size = 12
     translation_settings.normalization_alpha = 1.0
     return translation_settings
Beispiel #2
0
 def test_ende(self):
     with open('en-de/in', 'r', encoding='utf-8') as in_file, \
          open('en-de/out', 'w', encoding='utf-8') as out_file:
         os.chdir('models/en-de/')
         settings = TranslationSettings()
         settings.input = in_file
         settings.output = out_file
         settings.models = ["model.npz"]
         settings.beam_size = 12
         settings.normalization_alpha = 1.0
         translate(settings=settings)
         os.chdir('../..')
     self.outputEqual('en-de/ref2','en-de/out')
Beispiel #3
0
 def test_ende(self):
     with open('en-de/in', 'r', encoding='utf-8') as in_file, \
          open('en-de/out', 'w', encoding='utf-8') as out_file:
         os.chdir('models/en-de/')
         settings = TranslationSettings()
         settings.input = in_file
         settings.output = out_file
         settings.models = ["model.npz"]
         settings.beam_size = 12
         settings.normalization_alpha = 1.0
         translate(settings=settings)
         os.chdir('../..')
     self.outputEqual('en-de/ref2', 'en-de/out')