How to use the nlpaug.augmenter.char.KeyboardAug function in nlpaug

To help you get started, we’ve selected a few nlpaug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github makcedward / nlpaug / test / augmenter / char / test_keyboard.py View on Github external
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))
github makcedward / nlpaug / test / augmenter / char / test_char.py View on Github external
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)
github makcedward / nlpaug / test / augmenter / char / test_char.py View on Github external
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)
github makcedward / nlpaug / test / augmenter / char / test_keyboard.py View on Github external
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)
github makcedward / nlpaug / test / augmenter / char / test_keyboard.py View on Github external
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)