Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_no_special_character(self):
text = 'qwertyuioplmnbvcxza'
for i in range(10):
aug = nac.KeyboardAug(special_char=False)
augmented_text = aug.augment(text)
self.assertTrue(re.match("^[a-zA-Z0-9]*$", augmented_text))
def test_empty(self):
texts = ['', None]
augs = [
nac.OcrAug(),
nac.KeyboardAug(),
]
for text in texts:
for aug in augs:
augmented_text = aug.augment(text)
self.assertEqual(text, augmented_text)
def test_multi_thread(self):
text = 'The quick brown fox jumps over the lazy dog.'
n = 3
augs = [
nac.KeyboardAug(tokenizer=text_tokenizer.split_sentence),
nac.RandomCharAug(tokenizer=text_tokenizer.split_sentence),
]
for num_thread in [1, 3]:
for aug in augs:
augmented_data = aug.augment(text, n=n, num_thread=num_thread)
self.assertEqual(len(augmented_data), n)
def test_multi_words(self):
texts = ['The quick brown fox jumps over the lazy dog']
aug = nac.KeyboardAug()
for text in texts:
augmented_text = aug.augment(text)
self.assertNotEqual(text, augmented_text)
self.assertTrue(len(texts) > 0)
def test_single_word(self):
texts = ['Zoology', 'roku123456']
aug = nac.KeyboardAug()
for text in texts:
augmented_text = aug.augment(text)
self.assertNotEqual(text, augmented_text)
self.assertTrue(len(texts) > 0)