diff --git a/README.md b/README.md index 4360267..ea8254c 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,62 @@ word = "reactjs" remove_from_wordlist(word) ``` +If you want to remove multiple words at once, you can pass a list or a tuple to the function. Like this: + +```python +from lesp import remove_from_wordlist + +words = ["reactjs", "vuejs", "angularjs"] + +remove_from_wordlist(words) +``` + +### Stacking + +This function lets you stack two wordlist files together, so you can have a bigger wordlist out of two combined. The function will take two arguments, the source file and the destination file. The source file is the file that will be stacked on top of the destination file. Here's an example: + +```python +from lesp import stack + +stack("wordlist.txt", "my_wordlist.txt") +``` + +### Merge delete + +This function lets you delete all words from the destination file that are in the source file. For example, if you have a wordlist with the following words: + +``` +apple +banana +orange +``` + +And you have another wordlist with the following words: + +``` +apple +banana +raspberry +``` + +Then, if you use the `merge_delete` function, the destination file will be modified to look like this: + +``` +orange +raspberry +``` + +Here's an example of how you can use it: + +```python +from lesp import merge_delete + +merge_delete("wordlist.txt", "my_wordlist.txt") + +with open("my_wordlist.txt", "r") as f: + print(f.read()) +``` + ## Examples 📝 If you're still not sure where to use LESP, you can check out the `examples` folder. It contains some examples of how you can use LESP in your projects. These examples are pretty simple, but they should give you an idea of how you can use LESP in your projects. diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py index 1e54d6e..6af35c1 100644 --- a/lesp/autocorrect.py +++ b/lesp/autocorrect.py @@ -196,10 +196,14 @@ def merge_delete(source, destination): if not all(word.isalpha() for word in destination_words): raise ValueError("Invalid destination file format. Words must contain only alphabetic characters.") - destination_words = list(set(destination_words) - set(source_words)) + destination_words_ = list(set(destination_words) - set(source_words)) + + # All other words in the source file that are not in the destination file will be added to the destination file + + destination_words_ += [word for word in source_words if word not in destination_words] with open(destination, "w") as f: - f.write("\n".join(destination_words)) + f.write("\n".join(destination_words_)) except FileNotFoundError as e: raise FileNotFoundError(f"File not found: {str(e)}") except Exception as e: