Skip to content

Minor updates #185

New issue

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

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions spellchecker/spellchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,14 @@ def remove_by_threshold(self, threshold: int = 5) -> None:

def _update_dictionary(self) -> None:
"""Update the word frequency object"""
self._longest_word_length = 0
if not self._dictionary:
self._longest_word_length = 0
self._total_words = 0
self._unique_words = 0
self._letters = set()
return
keys = self._dictionary.keys()
self._longest_word_length = max(map(len, keys))
self._total_words = sum(self._dictionary.values())
self._unique_words = len(self._dictionary.keys())
self._letters = set()
for key in self._dictionary:
if len(key) > self._longest_word_length:
self._longest_word_length = len(key)
self._letters.update(key)
self._unique_words = len(keys)
self._letters = set().union(*keys)
4 changes: 2 additions & 2 deletions spellchecker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def decorator_wrapper(func):
def test_inner(*args, **kwargs):
if [int(x) for x in version.split(".")] <= [int(x) for x in __version__.split(".")]:
msg = (
f"The function {func.__name__} must be fully removed as it is depricated"
f"The function {func.__name__} must be fully removed as it is deprecated"
f" and must be removed by version {version}"
)
raise AssertionError(msg)
Expand Down Expand Up @@ -76,7 +76,7 @@ def ensure_unicode(value: KeyT, encoding: str = "utf-8") -> str:
if isinstance(value, bytes):
return value.decode(encoding)
elif isinstance(value, list):
raise TypeError(f"The provided value {value} is a not of type str or bytes")
raise TypeError(f"The provided value {value} is not of type str or bytes")
return value


Expand Down