Skip to content

Commit

Permalink
Merge pull request #14 from Parakrant/changesbypara
Browse files Browse the repository at this point in the history
Support Bulk Expansion #13 developed the function
  • Loading branch information
LyubomirT authored Nov 27, 2023
2 parents 716773c + 9fcd8a9 commit bd8ebc5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lesp/autocorrect.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,22 @@ def restore(overwritecurrent, path="wordlist_backup"):
raise ValueError(f"Error during restore: {str(e)}")

def extend_wordlist(word):
wordlist.append(word)
if isinstance(word, str):
if word.isalpha():
wordlist.append(word.lower())
else:
raise ValueError(f"Invalid input: '{word}' is not a valid word.")
elif isinstance(word, (list, tuple)):
for w in word:
if isinstance(w, str) and w.isalpha():
wordlist.append(w.lower())
else:
raise ValueError(f"Invalid input: '{word}' is not a valid word.")
else:
raise TypeError("Invalid input type. Please provide a string, list, or tuple of alphabetic words.")

def remove_from_wordlist(word):
if word not in wordlist:
raise ValueError(f"\"{word}\" not in wordlist!")
wordlist.remove(word)
wordlist.remove(word)

0 comments on commit bd8ebc5

Please sign in to comment.