We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug description:
Running the LeetLetters transformation on a sentence that produces no leet candidates return an IndexError: list index out of range:
LeetLetters
IndexError: list index out of range
To reproduce the error:
For example, a sentence with no alphanumeric characters.
from nlaugmenter.transformations.leet_letters.transformation import LeetLetters sentence = "-----------------------" t = LeetLetters(seed=0, max_outputs=5, max_leet=0.05) t.generate(sentence)
Cause:
The error comes from this section in the code:
leet_replacements = random.choices( leet_candidates, k=max_leet_replacements )
Since random.choices does not accept an empty list as argument, it returns an error whenleet_candidates is empty.
random.choices
leet_candidates
Possible fix:
if not leet_candidates: leet_replacements = [] else: leet_replacements = random.choices( leet_candidates, k=max_leet_replacements )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug description:
Running the
LeetLetters
transformation on a sentence that produces no leet candidates return anIndexError: list index out of range
:To reproduce the error:
For example, a sentence with no alphanumeric characters.
Cause:
The error comes from this section in the code:
Since
random.choices
does not accept an empty list as argument, it returns an error whenleet_candidates
is empty.Possible fix:
The text was updated successfully, but these errors were encountered: