(self)
| 442 | self.assertNotEqual(ex_after, ex) |
| 443 | |
| 444 | def test_tokenmask(self): |
| 445 | tokenmask_cls = get_transforms_cls(["tokenmask"])["tokenmask"] |
| 446 | opt = Namespace(seed=3434, tokenmask_temperature=0.1) |
| 447 | tokenmask_transform = tokenmask_cls(opt) |
| 448 | tokenmask_transform.warm_up() |
| 449 | ex = { |
| 450 | "src": ["Hello", ",", "world", "."], |
| 451 | "tgt": ["Bonjour", "le", "monde", "."], |
| 452 | } |
| 453 | # Not apply token mask for not training example |
| 454 | ex_after = tokenmask_transform.apply(copy.deepcopy(ex), is_train=False) |
| 455 | self.assertEqual(ex_after, ex) |
| 456 | # apply token mask for training example |
| 457 | ex_after = tokenmask_transform.apply(copy.deepcopy(ex), is_train=True) |
| 458 | self.assertNotEqual(ex_after, ex) |
| 459 | |
| 460 | def test_switchout(self): |
| 461 | switchout_cls = get_transforms_cls(["switchout"])["switchout"] |
nothing calls this directly
no test coverage detected