Skip to content

Commit 487d9c8

Browse files
authored
Merge pull request #294 from phunc20/fix/typo_candidiate
possible typo: candidate => candidiate
2 parents 14cf962 + 6689932 commit 487d9c8

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

nlpaug/augmenter/char/random.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ class RandomCharAug(CharAugmenter):
2929
:param int aug_word_max: Maximum number of word will be augmented. If None is passed, number of augmentation is
3030
calculated via aup_word_p. If calculated result from aug_word_p is smaller than aug_word_max, will use calculated result
3131
from aug_word_p. Otherwise, using aug_max.
32-
:param bool include_upper_case: If True, upper case character may be included in augmented data. If `candidiates'
32+
:param bool include_upper_case: If True, upper case character may be included in augmented data. If `candidates'
3333
value is provided, this param will be ignored.
34-
:param bool include_lower_case: If True, lower case character may be included in augmented data. If `candidiates'
34+
:param bool include_lower_case: If True, lower case character may be included in augmented data. If `candidates'
3535
value is provided, this param will be ignored.
36-
:param bool include_numeric: If True, numeric character may be included in augmented data. If `candidiates'
36+
:param bool include_numeric: If True, numeric character may be included in augmented data. If `candidates'
3737
value is provided, this param will be ignored.
3838
:param int min_char: If word less than this value, do not draw word for augmentation
3939
:param swap_mode: When action is 'swap', you may pass 'adjacent', 'middle' or 'random'. 'adjacent' means swap action
4040
only consider adjacent character (within same word). 'middle' means swap action consider adjacent character but
4141
not the first and last character of word. 'random' means swap action will be executed without constraint.
42-
:param str spec_char: Special character may be included in augmented data. If `candidiates'
42+
:param str spec_char: Special character may be included in augmented data. If `candidates'
4343
value is provided, this param will be ignored.
4444
:param list stopwords: List of words which will be skipped from augment operation.
4545
:param str stopwords_regex: Regular expression for matching words which will be skipped from augment operation.
4646
:param func tokenizer: Customize tokenization process
4747
:param func reverse_tokenizer: Customize reverse of tokenization process
48-
:param List candidiates: List of string for augmentation. E.g. ['AAA', '11', '===']. If values is provided,
48+
:param List candidates: List of string for augmentation. E.g. ['AAA', '11', '===']. If values is provided,
4949
`include_upper_case`, `include_lower_case`, `include_numeric` and `spec_char` will be ignored.
5050
:param str name: Name of this augmenter.
5151
@@ -56,7 +56,7 @@ class RandomCharAug(CharAugmenter):
5656
def __init__(self, action=Action.SUBSTITUTE, name='RandomChar_Aug', aug_char_min=1, aug_char_max=10, aug_char_p=0.3,
5757
aug_word_p=0.3, aug_word_min=1, aug_word_max=10, include_upper_case=True, include_lower_case=True,
5858
include_numeric=True, min_char=4, swap_mode='adjacent', spec_char='!@#$%^&*()_+', stopwords=None,
59-
tokenizer=None, reverse_tokenizer=None, verbose=0, stopwords_regex=None, candidiates=None):
59+
tokenizer=None, reverse_tokenizer=None, verbose=0, stopwords_regex=None, candidates=None):
6060
super().__init__(
6161
action=action, name=name, min_char=min_char, aug_char_min=aug_char_min, aug_char_max=aug_char_max,
6262
aug_char_p=aug_char_p, aug_word_min=aug_word_min, aug_word_max=aug_word_max, aug_word_p=aug_word_p,
@@ -68,7 +68,7 @@ def __init__(self, action=Action.SUBSTITUTE, name='RandomChar_Aug', aug_char_min
6868
self.include_numeric = include_numeric
6969
self.swap_mode = swap_mode
7070
self.spec_char = spec_char
71-
self.candidiates = candidiates
71+
self.candidates = candidates
7272

7373
self.model = self.get_model()
7474

@@ -248,8 +248,8 @@ def delete(self, data):
248248
return self.reverse_tokenizer(doc.get_augmented_tokens())
249249

250250
def get_model(self):
251-
if self.candidiates:
252-
return self.candidiates
251+
if self.candidates:
252+
return self.candidates
253253

254254
candidates = []
255255
if self.include_upper_case:

nlpaug/model/lang_models/language_models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class LanguageModels:
1414
OPTIMIZE_ATTRIBUTES = ['external_memory', 'return_proba']
1515

16-
def __init__(self, device='cpu', model_type='', temperature=1.0, top_k=100, top_p=0.01, batch_size=32,
16+
def __init__(self, device='cpu', model_type='', temperature=1.0, top_k=100, top_p=0.01, batch_size=32,
1717
optimize=None, silence=True):
1818
try:
1919
import torch
@@ -60,7 +60,7 @@ def clean(self, text):
6060
def predict(self, text, target_word=None, n=1):
6161
raise NotImplementedError
6262

63-
# for HuggingFace pipeline
63+
# for HuggingFace pipeline
6464
def convert_device(self, device):
6565
if device == 'cpu' or device is None:
6666
return -1
@@ -158,7 +158,7 @@ def filtering(self, logits, seed):
158158
def pick(self, logits, idxes, target_word, n=1, include_punctuation=False):
159159
candidate_ids, candidate_probas = self.prob_multinomial(logits, n=n*10)
160160
candidate_ids = [idxes[candidate_id] for candidate_id in candidate_ids]
161-
results = self.get_candidiates(candidate_ids, candidate_probas, target_word, n,
161+
results = self.get_candidates(candidate_ids, candidate_probas, target_word, n,
162162
include_punctuation)
163163

164164
return results
@@ -183,7 +183,7 @@ def prob_multinomial(self, logits, n):
183183
def is_skip_candidate(self, candidate):
184184
return False
185185

186-
def get_candidiates(self, candidate_ids, candidate_probas, target_word=None, n=1,
186+
def get_candidates(self, candidate_ids, candidate_probas, target_word=None, n=1,
187187
include_punctuation=False):
188188
# To have random behavior, NO sorting for candidate_probas.
189189
results = []

test/augmenter/char/test_random_char.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ def test_swap_random(self):
135135
self.assertNotEqual(text, augmented_text)
136136
self.assertEqual(len(augmented_text), len(text))
137137

138-
def test_candidiates(self):
139-
candidiates = ['AAA', '11', '===', '中文']
138+
def test_candidates(self):
139+
candidates = ['AAA', '11', '===', '中文']
140140
text = 'quick brown jumps over lazy'
141-
aug = RandomCharAug(min_char=4, candidiates=candidiates)
141+
aug = RandomCharAug(min_char=4, candidates=candidates)
142142
augmented_text = aug.augment(text)
143143
self.assertNotEqual(text, augmented_text)
144144

145145
match = False
146-
for c in candidiates:
146+
for c in candidates:
147147
if c in augmented_text:
148148
match = True
149149
break

0 commit comments

Comments
 (0)