From 922812b1ae6c5112b62d4ce00ddd44ffc90a7b72 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Sun, 26 Nov 2023 21:16:31 +0200
Subject: [PATCH 01/23] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a6c4033..a4550f9 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
---
-
+
From 275a11ada7c37bf14e5921bd88cdca93046ee8d6 Mon Sep 17 00:00:00 2001
From: y9rabbito
Date: Mon, 27 Nov 2023 10:37:39 +0530
Subject: [PATCH 02/23] Implement error handler that validates the structure of
a wordlist or backup file while loading
---
lesp/autocorrect.py | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 02190bb..7040fcd 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -13,6 +13,8 @@ def load_wordlist():
try:
with open(wordlistpath, "r") as f:
wordlist = f.read().split("\n")
+ if not all(word.isalpha() for word in wordlist):
+ raise ValueError("Invalid wordlist format. Words must contain only alphabetic characters.")
return wordlist
except FileNotFoundError:
raise FileNotFoundError(f"{wordlistpath} not found!")
@@ -95,15 +97,24 @@ def backup(path="wordlist_backup"):
def restore(overwritecurrent, path="wordlist_backup"):
- if not os.path.isfile(path):
- raise FileNotFoundError("Backup file not found!")
- with open(path, "r") as f:
- wordlist_ = f.read().split("\n")
- global wordlist
- wordlist = wordlist_
- if overwritecurrent:
- with open(wordlistpath, "w") as f:
- f.write("\n".join(wordlist))
+ try:
+ if not os.path.isfile(path):
+ raise FileNotFoundError("Backup file not found!")
+
+ with open(path, "r") as f:
+ wordlist_ = f.read().split("\n")
+
+ if not all(word.isalpha() for word in wordlist_):
+ raise ValueError("Invalid backup file format. Words must contain only alphabetic characters.")
+
+ global wordlist
+ wordlist = wordlist_
+
+ if overwritecurrent:
+ with open(wordlistpath, "w") as f:
+ f.write("\n".join(wordlist))
+ except Exception as e:
+ raise ValueError(f"Error during restore: {str(e)}")
def extend_wordlist(word):
wordlist.append(word)
From 4f8460b108c2356ad627563ff82e260ec6f0dcaa Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 08:10:23 +0200
Subject: [PATCH 03/23] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a4550f9..168fd46 100644
--- a/README.md
+++ b/README.md
@@ -218,7 +218,7 @@ You can contact me on Discord either in my [Discord Server](https://discord.gg/X
- [ ] Optimize even further
- [ ] Add more examples
-- [ ] Improve documentation
+- [x] Improve documentation
- [ ] Add support for compounds
## License 📜
@@ -236,4 +236,4 @@ Many thanks to the following Open-Source projects:
Thanks to these awesome people for contributing! I appreciate your support a lot! ❤️
-![Contributors](https://contrib.rocks/image?repo=LyubomirT/lesp)
\ No newline at end of file
+![Contributors](https://contrib.rocks/image?repo=LyubomirT/lesp)
From f074e39b7b5f0e24967c3afeb01d41697ea4ffe2 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 08:14:31 +0200
Subject: [PATCH 04/23] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 168fd46..0025e5e 100644
--- a/README.md
+++ b/README.md
@@ -219,7 +219,7 @@ You can contact me on Discord either in my [Discord Server](https://discord.gg/X
- [ ] Optimize even further
- [ ] Add more examples
- [x] Improve documentation
-- [ ] Add support for compounds
+- [ ] Add support for conjugations
## License 📜
From ac39fcba8301e5c668bc746306eefd09e505887b Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 08:17:29 +0200
Subject: [PATCH 05/23] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 0025e5e..2656e71 100644
--- a/README.md
+++ b/README.md
@@ -218,7 +218,7 @@ You can contact me on Discord either in my [Discord Server](https://discord.gg/X
- [ ] Optimize even further
- [ ] Add more examples
-- [x] Improve documentation
+- [ ] Improve documentation
- [ ] Add support for conjugations
## License 📜
From 716773c53b9cc7f4198d2f7ba4a4245566630a0b Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 08:17:42 +0200
Subject: [PATCH 06/23] Update README.md
---
README.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/README.md b/README.md
index 2656e71..60a6104 100644
--- a/README.md
+++ b/README.md
@@ -219,7 +219,6 @@ You can contact me on Discord either in my [Discord Server](https://discord.gg/X
- [ ] Optimize even further
- [ ] Add more examples
- [ ] Improve documentation
-- [ ] Add support for conjugations
## License 📜
From bf9690a65e7d5e2c5ec03544da208ee5f5153645 Mon Sep 17 00:00:00 2001
From: parakrant
Date: Mon, 27 Nov 2023 16:36:44 +0800
Subject: [PATCH 07/23] Support Bulk Expansion #13 developed the function
---
lesp/bulkexpansion.py | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 lesp/bulkexpansion.py
diff --git a/lesp/bulkexpansion.py b/lesp/bulkexpansion.py
new file mode 100644
index 0000000..b53c645
--- /dev/null
+++ b/lesp/bulkexpansion.py
@@ -0,0 +1,40 @@
+def bulkexpansion_wordlist(wordlist, words):
+ if isinstance(words, str):
+ # If a single word is provided, add it to the wordlist
+ if words.isalpha():
+ wordlist.append(words)
+ else:
+ raise ValueError(f"Invalid input: '{words}' is not a valid word.")
+ elif isinstance(words, (list, tuple)):
+ # If a list or tuple is provided, extend the wordlist with its elements
+ for word in words:
+ if isinstance(word, str) and word.isalpha():
+ wordlist.append(word)
+ else:
+ raise ValueError(f"Invalid input: '{word}' is not a valid word.")
+ else:
+ # Handle other types if needed
+ raise TypeError("Invalid input type. Please provide a string, list, or tuple of alphabetic words.")
+
+ return wordlist
+
+# Example usage:
+wordlist = []
+# Can link worldlist from the config file if needed
+
+# Adding individual words
+wordlist = bulkexpansion_wordlist(wordlist, "apple")
+# This will raise a ValueError
+wordlist = bulkexpansion_wordlist(wordlist, "123")
+
+# Adding a list of words
+word_list = ["orange", "grape", "kiwi"]
+wordlist = bulkexpansion_wordlist(wordlist, word_list)
+
+# Adding a tuple of words
+word_tuple = ("melon", "pear", "pineapple", 456)
+# This will raise a ValueError
+# wordlist = bulkexpansion_wordlist(wordlist, word_tuple)
+
+# Get the expanded wordlist
+print(wordlist)
From 5e619a7f908cc5095cde9dc400ec9b60dd94edcf Mon Sep 17 00:00:00 2001
From: parakrant
Date: Mon, 27 Nov 2023 17:20:31 +0800
Subject: [PATCH 08/23] updated extend_wordlist
---
lesp/autocorrect.py | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 7040fcd..7a83210 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -117,9 +117,29 @@ def restore(overwritecurrent, path="wordlist_backup"):
raise ValueError(f"Error during restore: {str(e)}")
def extend_wordlist(word):
+ if isinstance(word, str):
+ # If a single word is provided, add it to the wordlist
+ if word.isalpha():
+ wordlist.append(word)
+ else:
+ raise ValueError(f"Invalid input: '{word}' is not a valid word.")
+ elif isinstance(word, (list, tuple)):
+ # If a list or tuple is provided, extend the wordlist with its elements
+ for w in word:
+ if isinstance(w, str) and w.isalpha():
+ wordlist.append(w)
+ else:
+ raise ValueError(f"Invalid input: '{word}' is not a valid word.")
+ else:
+ # Handle other types if needed
+ raise TypeError("Invalid input type. Please provide a string, list, or tuple of alphabetic words.")
+
+ return wordlist
+
wordlist.append(word)
def remove_from_wordlist(word):
if word not in wordlist:
raise ValueError(f"\"{word}\" not in wordlist!")
- wordlist.remove(word)
\ No newline at end of file
+ wordlist.remove(word)
+
From 4f35b9d9388957b20a8f903f2b5be86488d5ee2f Mon Sep 17 00:00:00 2001
From: parakrant
Date: Mon, 27 Nov 2023 17:22:42 +0800
Subject: [PATCH 09/23] del bulkexpansion.py
---
lesp/bulkexpansion.py | 40 ----------------------------------------
1 file changed, 40 deletions(-)
delete mode 100644 lesp/bulkexpansion.py
diff --git a/lesp/bulkexpansion.py b/lesp/bulkexpansion.py
deleted file mode 100644
index b53c645..0000000
--- a/lesp/bulkexpansion.py
+++ /dev/null
@@ -1,40 +0,0 @@
-def bulkexpansion_wordlist(wordlist, words):
- if isinstance(words, str):
- # If a single word is provided, add it to the wordlist
- if words.isalpha():
- wordlist.append(words)
- else:
- raise ValueError(f"Invalid input: '{words}' is not a valid word.")
- elif isinstance(words, (list, tuple)):
- # If a list or tuple is provided, extend the wordlist with its elements
- for word in words:
- if isinstance(word, str) and word.isalpha():
- wordlist.append(word)
- else:
- raise ValueError(f"Invalid input: '{word}' is not a valid word.")
- else:
- # Handle other types if needed
- raise TypeError("Invalid input type. Please provide a string, list, or tuple of alphabetic words.")
-
- return wordlist
-
-# Example usage:
-wordlist = []
-# Can link worldlist from the config file if needed
-
-# Adding individual words
-wordlist = bulkexpansion_wordlist(wordlist, "apple")
-# This will raise a ValueError
-wordlist = bulkexpansion_wordlist(wordlist, "123")
-
-# Adding a list of words
-word_list = ["orange", "grape", "kiwi"]
-wordlist = bulkexpansion_wordlist(wordlist, word_list)
-
-# Adding a tuple of words
-word_tuple = ("melon", "pear", "pineapple", 456)
-# This will raise a ValueError
-# wordlist = bulkexpansion_wordlist(wordlist, word_tuple)
-
-# Get the expanded wordlist
-print(wordlist)
From a0cf7566e1b6cde4222b452913e08c15653f7d0a Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 11:27:11 +0200
Subject: [PATCH 10/23] Update autocorrect.py
---
lesp/autocorrect.py | 7 -------
1 file changed, 7 deletions(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 7a83210..60616ab 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -118,26 +118,19 @@ def restore(overwritecurrent, path="wordlist_backup"):
def extend_wordlist(word):
if isinstance(word, str):
- # If a single word is provided, add it to the wordlist
if word.isalpha():
wordlist.append(word)
else:
raise ValueError(f"Invalid input: '{word}' is not a valid word.")
elif isinstance(word, (list, tuple)):
- # If a list or tuple is provided, extend the wordlist with its elements
for w in word:
if isinstance(w, str) and w.isalpha():
wordlist.append(w)
else:
raise ValueError(f"Invalid input: '{word}' is not a valid word.")
else:
- # Handle other types if needed
raise TypeError("Invalid input type. Please provide a string, list, or tuple of alphabetic words.")
- return wordlist
-
- wordlist.append(word)
-
def remove_from_wordlist(word):
if word not in wordlist:
raise ValueError(f"\"{word}\" not in wordlist!")
From 9fcd8a9be85e315740a403f1e1c66c48656eb253 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 11:29:32 +0200
Subject: [PATCH 11/23] Update autocorrect.py
---
lesp/autocorrect.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 60616ab..38aef28 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -119,13 +119,13 @@ def restore(overwritecurrent, path="wordlist_backup"):
def extend_wordlist(word):
if isinstance(word, str):
if word.isalpha():
- wordlist.append(word)
+ 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)
+ wordlist.append(w.lower())
else:
raise ValueError(f"Invalid input: '{word}' is not a valid word.")
else:
From d04afa4e9d53e19cab0749696f9692a5f22ed3b5 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 09:36:25 +0000
Subject: [PATCH 12/23] Add another code example to README.md
---
README.md | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/README.md b/README.md
index 60a6104..5ac68ca 100644
--- a/README.md
+++ b/README.md
@@ -159,6 +159,16 @@ if not is_correct("reactjs") and get_similar("reactjs") is None:
pass
```
+You can also extend the wordlist with multiple words at once by passing a list or a tuple to the function. Like this:
+
+```python
+from lesp import extend_wordlist
+
+words = ["reactjs", "vuejs", "angularjs"]
+
+extend_wordlist(words)
+```
+
### Remove from wordlist
An opposite of the `extend_wordlist` function, this function removes a word from the wordlist. Note that this function will raise a `ValueError` if the word is not in the wordlist. Also note that this function will not remove the word from the wordlist permanently, it will only remove it for the current session. Here's an example:
From bc37afc79db9150b6be753daac13b68b981004fa Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 11:42:42 +0200
Subject: [PATCH 13/23] Update README.md
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 5ac68ca..4360267 100644
--- a/README.md
+++ b/README.md
@@ -245,4 +245,6 @@ Many thanks to the following Open-Source projects:
Thanks to these awesome people for contributing! I appreciate your support a lot! ❤️
-![Contributors](https://contrib.rocks/image?repo=LyubomirT/lesp)
+
+
+
From b9be8f7335e54db6e152ffd17c51bdb0486abdb7 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 09:53:52 +0000
Subject: [PATCH 14/23] Add stack and merge_delete functions to autocorrect.py
---
lesp/autocorrect.py | 52 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 38aef28..506d579 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -136,3 +136,55 @@ def remove_from_wordlist(word):
raise ValueError(f"\"{word}\" not in wordlist!")
wordlist.remove(word)
+
+def stack(source, destination):
+ try:
+ with open(source, "r") as f:
+ source_words = f.read().split("\n")
+ with open(destination, "r") as f:
+ destination_words = f.read().split("\n")
+
+ if any(len(word.split()) > 1 for word in source_words):
+ raise ValueError("Invalid source file format. Each word must be on a separate line.")
+ if any(len(word.split()) > 1 for word in destination_words):
+ raise ValueError("Invalid destination file format. Each word must be on a separate line.")
+
+ if not all(word.isalpha() for word in source_words):
+ raise ValueError("Invalid source file format. Words must contain only alphabetic characters.")
+ if not all(word.isalpha() for word in destination_words):
+ raise ValueError("Invalid destination file format. Words must contain only alphabetic characters.")
+
+ destination_words.extend(source_words)
+
+ with open(destination, "w") as f:
+ f.write("\n".join(destination_words))
+ except FileNotFoundError as e:
+ raise FileNotFoundError(f"File not found: {str(e)}")
+ except Exception as e:
+ raise ValueError(f"Error during stacking: {str(e)}")
+
+def merge_delete(source, destination):
+ try:
+ with open(source, "r") as f:
+ source_words = f.read().split("\n")
+ with open(destination, "r") as f:
+ destination_words = f.read().split("\n")
+
+ if any(len(word.split()) > 1 for word in source_words):
+ raise ValueError("Invalid source file format. Each word must be on a separate line.")
+ if any(len(word.split()) > 1 for word in destination_words):
+ raise ValueError("Invalid destination file format. Each word must be on a separate line.")
+
+ if not all(word.isalpha() for word in source_words):
+ raise ValueError("Invalid source file format. Words must contain only alphabetic characters.")
+ 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))
+
+ with open(destination, "w") as f:
+ f.write("\n".join(destination_words))
+ except FileNotFoundError as e:
+ raise FileNotFoundError(f"File not found: {str(e)}")
+ except Exception as e:
+ raise ValueError(f"Error during merge delete: {str(e)}")
From 9259d167656ab4df9dba8bcf746256b366c5ab43 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 09:55:21 +0000
Subject: [PATCH 15/23] Refactor remove_from_wordlist function to handle
multiple inputs
---
lesp/autocorrect.py | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 506d579..1e54d6e 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -132,9 +132,25 @@ def extend_wordlist(word):
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)
+ if isinstance(word, str):
+ if word.isalpha():
+ if word in wordlist:
+ wordlist.remove(word)
+ else:
+ raise ValueError(f"\"{word}\" not in wordlist!")
+ 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():
+ if w in wordlist:
+ wordlist.remove(w)
+ else:
+ raise ValueError(f"\"{w}\" not in wordlist!")
+ 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 stack(source, destination):
From c90982061e7aa398ec38a8105a8425b2d848b79f Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 10:07:06 +0000
Subject: [PATCH 16/23] Fix merge_delete function to add missing words to
destination file
Improve README.
---
README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++
lesp/autocorrect.py | 8 +++++--
2 files changed, 62 insertions(+), 2 deletions(-)
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:
From 5e1e0584951c7f979039e4e96c756c8c57f8f642 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 12:20:19 +0200
Subject: [PATCH 17/23] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index ea8254c..3fa7671 100644
--- a/README.md
+++ b/README.md
@@ -102,7 +102,7 @@ In the code above, we're getting similar words to `apgle` with a similarity rate
A similarity rate of `0.5` means that the words returned will be at least 50% similar to the word we're checking. The higher the similarity rate, the more precise the results will be, but generally there will be less words. Myself I would recommend to keep the similarity rate at `0.5`, but you can experiment with it and see what works best for you.
-The `chunks` argument specifies how many chunks the wordlist will be split into. This is useful if you have a large wordlist and you want to speed up the process. The higher the number, the faster the process will be, but the more memory/CPU it will consume. For example, when trying to scan `wordlist.txt` with 500 chunks, the process takes about 0.5 seconds on my machine, but it consumes about 1.5 GB of RAM and 44% of one of the CPU cores. If you have a large wordlist.
+The `chunks` argument specifies how many chunks the wordlist will be split into. This is useful if you have a large wordlist and you want to speed up the process. The higher the number, the faster the process will be, but the more memory/CPU it will consume. For example, when trying to scan `wordlist.txt` with 1500 chunks, the process takes about 0.5 seconds on my machine, but it consumes about 1.5 GB of RAM and 44% of one of the CPU cores. If you have a large wordlist.
The `upto` argument specifies how many similar words will be returned. If you set it to `3`, then the function will return up to 3 similar words. If you set it to `1`, then it will return up to 1 similar word. But, whatever amount you select, the output will still be a list. If you set it to `0`, then the function will raise a `ValueError`.
From 1208f58e2d44ef3a2c12bf8e9c30ca2b6760cd30 Mon Sep 17 00:00:00 2001
From: "deepsource-io[bot]"
<42547082+deepsource-io[bot]@users.noreply.github.com>
Date: Mon, 27 Nov 2023 11:41:57 +0000
Subject: [PATCH 18/23] ci: add .deepsource.toml
---
.deepsource.toml | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
create mode 100644 .deepsource.toml
diff --git a/.deepsource.toml b/.deepsource.toml
new file mode 100644
index 0000000..420b2aa
--- /dev/null
+++ b/.deepsource.toml
@@ -0,0 +1,18 @@
+version = 1
+
+exclude_patterns = [
+ "config",
+ "demo_config",
+ ".gitignore",
+ "LICENSE",
+ "README.md",
+ "CONTRIBUTING.md",
+ "small_wordlist.txt",
+ "wordlist.txt"
+]
+
+[[analyzers]]
+name = "python"
+
+ [analyzers.meta]
+ runtime_version = "3.x.x"
\ No newline at end of file
From d8cc4237028f430282b19778986c988630934cf6 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 13:45:01 +0200
Subject: [PATCH 19/23] Update autocorrect.py
---
lesp/autocorrect.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lesp/autocorrect.py b/lesp/autocorrect.py
index 6af35c1..915f6f3 100644
--- a/lesp/autocorrect.py
+++ b/lesp/autocorrect.py
@@ -28,10 +28,7 @@ def load_wordlist():
exit()
def is_correct(word):
- if word in wordlist:
- return True
- else:
- return False
+ return word in wordlist
def get_similarity_score(word1, word2):
len1 = len(word1)
From 6908536aa459e04623a54b1dd5d7be71474236f6 Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Mon, 27 Nov 2023 18:13:30 +0200
Subject: [PATCH 20/23] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 3fa7671..9a06bf7 100644
--- a/README.md
+++ b/README.md
@@ -302,5 +302,5 @@ Many thanks to the following Open-Source projects:
Thanks to these awesome people for contributing! I appreciate your support a lot! ❤️
-
+
From e2550b902cce31b9735c5927318ca31a334f9f7a Mon Sep 17 00:00:00 2001
From: Hazim Alzorgan
Date: Mon, 27 Nov 2023 21:19:33 -0500
Subject: [PATCH 21/23] added two more example games
---
examples/Fill In The Blanks/main.py | 27 +++++++++++++++++++++++++++
examples/Word Jumble Game/main.py | 21 +++++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100644 examples/Fill In The Blanks/main.py
create mode 100644 examples/Word Jumble Game/main.py
diff --git a/examples/Fill In The Blanks/main.py b/examples/Fill In The Blanks/main.py
new file mode 100644
index 0000000..969f9e3
--- /dev/null
+++ b/examples/Fill In The Blanks/main.py
@@ -0,0 +1,27 @@
+#from lesp import is_correct
+from lesp.autocorrect import is_correct, get_similar
+import random
+
+# Load words from wordlist file
+with open("wordlist.txt", "r") as f:
+ words = [word.strip() for word in f.readlines()]
+random_word = random.choice(words)
+
+# Create a word with blanks
+word_with_blanks = ""
+for i, letter in enumerate(random_word):
+ if i % 2 == 0:
+ word_with_blanks += letter
+ else:
+ word_with_blanks += "_"
+
+print("Fill in the blanks:", word_with_blanks)
+
+# User input
+user_input = input("Your guess: ")
+
+# Check spelling
+if user_input.lower() == random_word:
+ print("Correct!")
+else:
+ print(f"Incorrect. The correct word is '{random_word}'.")
\ No newline at end of file
diff --git a/examples/Word Jumble Game/main.py b/examples/Word Jumble Game/main.py
new file mode 100644
index 0000000..031111c
--- /dev/null
+++ b/examples/Word Jumble Game/main.py
@@ -0,0 +1,21 @@
+#from lesp import is_correct
+from lesp.autocorrect import is_correct, get_similar
+import random
+
+# Load words from wordlist file
+with open("wordlist.txt", "r") as f:
+ words = [word.strip() for word in f.readlines()]
+
+# Pick a random word and scramble it
+word = random.choice(words)
+scrambled = ''.join(random.sample(word, len(word)))
+print("Unscramble this word:", scrambled)
+
+# User guesses
+guess = input("Your guess: ")
+
+# Check if guess is correct
+if guess.lower() == word:
+ print("Correct!")
+else:
+ print(f"Incorrect. The correct word was '{word}'.")
From 619a9868339afd55557c115a5bb22abd7ebec2cf Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Tue, 28 Nov 2023 08:40:58 +0200
Subject: [PATCH 22/23] Update README.md
---
README.md | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 9a06bf7..6c3675e 100644
--- a/README.md
+++ b/README.md
@@ -301,6 +301,4 @@ Many thanks to the following Open-Source projects:
Thanks to these awesome people for contributing! I appreciate your support a lot! ❤️
-
-
-
+[![Contributors](https://contrib.rocks/image?repo=lyubomirt/lesp)](https://github.com/lyubomirt/lesp/graphs/contributors)
From 53d92931cf54ae7668a50a163975e2e92a24b9cf Mon Sep 17 00:00:00 2001
From: Lyubomir Ternavskiy <127299159+LyubomirT@users.noreply.github.com>
Date: Tue, 28 Nov 2023 16:52:25 +0200
Subject: [PATCH 23/23] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 6c3675e..c92504d 100644
--- a/README.md
+++ b/README.md
@@ -302,3 +302,5 @@ Many thanks to the following Open-Source projects:
Thanks to these awesome people for contributing! I appreciate your support a lot! ❤️
[![Contributors](https://contrib.rocks/image?repo=lyubomirt/lesp)](https://github.com/lyubomirt/lesp/graphs/contributors)
+
+(Note that due to a glitch, some contributors may not appear in the grid)