From ffd3f4e916a262877708b7cde63e6fde04cffba7 Mon Sep 17 00:00:00 2001 From: barrust Date: Mon, 15 Jan 2024 08:17:03 -0500 Subject: [PATCH] version bump --- .github/workflows/python-package.yml | 2 +- CHANGELOG.md | 2 +- pyproject.toml | 23 ++++++++++------------- spellchecker/info.py | 2 +- spellchecker/spellchecker.py | 18 ++++++++++-------- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index f2be346..9c9fc43 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acf3b4..25b8ffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # pyspellchecker -## Version 0.7.4 +## Version 0.8.0 * Leveraged the dictionary files from [levidromelist](https://www.levidromelist.com/levidrome-list/dictionary) to attempt to clean up the `en`, `es`, `fr`, `pt`, `'de`, and `nl`dictionaries; Attempts to resolve issues #164, #155, #150, #140, #115, and #107; see [issue #126](https://github.com/barrust/pyspellchecker/issues/126) * Added `Italian` language support; see [#167](https://github.com/barrust/pyspellchecker/pull/167) diff --git a/pyproject.toml b/pyproject.toml index 4dcd627..cca041c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [project] name = "pyspellchecker" dynamic = ["version"] -authors = [{name = "Tyler Barrus", email = "barrust@gmail.com"}] -license = {text = "MIT"} +authors = [{ name = "Tyler Barrus", email = "barrust@gmail.com" }] +license = { text = "MIT" } description = "Pure python spell checker based on work by Peter Norvig" keywords = [ "python", @@ -30,12 +30,13 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] requires-python = ">=3.6" [tool.setuptools.dynamic] -version = {attr = "spellchecker.__version__"} +version = { attr = "spellchecker.__version__" } [project.urls] @@ -45,16 +46,14 @@ documentation = "https://pyspellchecker.readthedocs.io/" [tool.poetry] -packages = [ - {include = "spellchecker"}, -] +packages = [{ include = "spellchecker" }] [tool.poetry.dev-dependencies] -pre-commit = {version = ">=2.18.1", python = "^3.6.1"} -black = {version = "^20.8b1", python = "^3.6"} -isort = {version = "^5.6.4", python = "^3.6"} -pytest = {version = "^6.1.1", python = "^3.6"} -flake8 = {version = "^3.6.0", python = "^3.6"} +pre-commit = { version = ">=2.18.1", python = "^3.6.1" } +black = { version = "^20.8b1", python = "^3.6" } +isort = { version = "^5.6.4", python = "^3.6" } +pytest = { version = "^6.1.1", python = "^3.6" } +flake8 = { version = "^3.6.0", python = "^3.6" } [tool.setuptools.packages.find] include = ["spellchecker", "spellchecker.*"] @@ -89,5 +88,3 @@ max-args = 6 [build-system] requires = ["setuptools>=61.2.0", "wheel"] build-backend = "setuptools.build_meta" - - diff --git a/spellchecker/info.py b/spellchecker/info.py index 83d6b7b..eadec0c 100644 --- a/spellchecker/info.py +++ b/spellchecker/info.py @@ -5,7 +5,7 @@ __maintainer__ = "Tyler Barrus" __email__ = "barrust@gmail.com" __license__ = "MIT" -__version__ = "0.7.3" +__version__ = "0.8.0" __credits__ = ["Peter Norvig"] __url__ = "https://github.com/barrust/pyspellchecker" __bugtrack_url__ = f"{__url__}/issues" diff --git a/spellchecker/spellchecker.py b/spellchecker/spellchecker.py index f1c84e9..d9ac0a8 100644 --- a/spellchecker/spellchecker.py +++ b/spellchecker/spellchecker.py @@ -286,16 +286,16 @@ def __init__( tokenizer: typing.Optional[typing.Callable[[str], typing.Iterable[str]]] = None, case_sensitive: bool = False, ) -> None: - self._dictionary = Counter() + self._dictionary: typing.Counter = Counter() self._total_words = 0 self._unique_words = 0 - self._letters = set() + self._letters: typing.Set[str] = set() self._case_sensitive = case_sensitive self._longest_word_length = 0 self._tokenizer = _parse_into_words if tokenizer is not None: - self._tokenizer = tokenizer + self._tokenizer = tokenizer # type: ignore def __contains__(self, key: KeyT) -> bool: """turn on contains""" @@ -313,13 +313,15 @@ def __iter__(self) -> typing.Generator[str, None, None]: """turn on iter support""" yield from self._dictionary - def pop(self, key: KeyT, default: typing.Optional[int] = None) -> int: + def pop(self, key: KeyT, default: typing.Optional[int] = None) -> typing.Optional[int]: """Remove the key and return the associated value or default if not found Args: key (str): The key to remove - default (obj): The value to return if key is not present""" + default (obj): The value to return if key is not present + Returns: + int | None: Returns the number of instances of key, or None if not in the dictionary""" key = ensure_unicode(key) return self._dictionary.pop(key if self._case_sensitive else key.lower(), default) @@ -364,7 +366,7 @@ def longest_word_length(self) -> int: Not settable""" return self._longest_word_length - def tokenize(self, text: KeyT) -> typing.Generator[str, None, None]: + def tokenize(self, text: KeyT) -> typing.Iterator[str]: """Tokenize the provided string object into individual words Args: @@ -377,7 +379,7 @@ def tokenize(self, text: KeyT) -> typing.Generator[str, None, None]: for word in self._tokenizer(tmp_text): yield word if self._case_sensitive else word.lower() - def keys(self) -> typing.Generator[str, None, None]: + def keys(self) -> typing.Iterator[str]: """Iterator over the key of the dictionary Yields: @@ -386,7 +388,7 @@ def keys(self) -> typing.Generator[str, None, None]: This is the same as `spellchecker.words()`""" yield from self._dictionary.keys() - def words(self) -> typing.Generator[str, None, None]: + def words(self) -> typing.Iterator[str]: """Iterator over the words in the dictionary Yields: