Exemplo n.º 1
0
 def main(self):
     dict_fn = self.langs_conf['biling'][
         '{}-{}'.format(*sorted([self.sr_code, self.tg_code]))][
             self.params['dict_i'][0]]
     source_fn = self.langs_conf['mono'][self.sr_code]['embed'][self.params[
         'embed_i'][0]]
     target_fn = self.get_tg_embed(self.tg_code, self.params)
     dinu_args = {'seed_fn': dict_fn.format(self.tg_code, self.sr_code),
                  'source_fn': source_fn,
                  'target_fn': target_fn,
                  'reverse': True}
     for key in ['additional', 'train_size']:
         dinu_args[key] = self.params[key] 
     return 1 - train_test_wrapper(*dinu_args)
Exemplo n.º 2
0
 def main(self, params):
     pair = ['de', 'hu']
     sr_code = pair[params['reverse'][0]]
     tg_code = pair[1 - params['reverse'][0]]
     embed_i = [params['de_embed_i'][0], params['hu_embed_i'][0]]
     if params['reverse'][0]:
         embed_i = tuple(reversed(embed_i))
     dict_fn = self.langs_conf['biling'][
         '{}-{}'.format(*sorted([sr_code, tg_code]))][
             params['dict_i'][0]]
     source_fn = self.langs_conf['mono'][sr_code]['embed'][embed_i[0]]
     target_fn = self.langs_conf['mono'][tg_code]['embed'][embed_i[1]]
     dinu_args = argparse.Namespace()
     dinu_args_d = vars(dinu_args)
     dinu_args_d.update({
         'seed_fn': dict_fn.format(*pair),
         'source_fn': source_fn,
         'target_fn': target_fn,
         'reverse': params['reverse'][0]})
     for key in ['additional', 'train_size']:
         dinu_args_d[key] = params[key][0]
     return 1 - train_test_wrapper(dinu_args)