Skip to content

Commit

Permalink
Upgrade to python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-lerner authored Jan 18, 2023
2 parents 897f19f + f671e20 commit 43f138f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest , macos-latest, windows-latest]
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pywordfreq"
version = "0.3.1"
version = "0.4.0"
authors = ["Gal Ben David <[email protected]>"]
edition = "2021"
description = "Word frequency checker based on Wikipedia corpus written in Rust"
Expand All @@ -27,6 +27,7 @@ classifier = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Rust",
]

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


![license](https://img.shields.io/badge/MIT-License-blue)
![Python](https://img.shields.io/badge/Python-3.7%20%7C%203.8%20%7C%203.9-blue)
![Python](https://img.shields.io/badge/Python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue)
![OS](https://img.shields.io/badge/OS-Mac%20%7C%20Linux%20%7C%20Windows-blue)
![Build](https://github.com/intsights/pywordfreq/workflows/Build/badge.svg)
[![PyPi](https://img.shields.io/pypi/v/pywordfreq.svg)](https://pypi.org/project/pywordfreq/)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sdist-include = [

[tool.poetry]
name = "pywordfreq"
version = "0.3.1"
version = "0.4.0"
authors = ["Gal Ben David <[email protected]>"]
description = "Word frequency checker based on Wikipedia corpus written in Rust"
readme = "README.md"
Expand All @@ -35,6 +35,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Rust",
]

Expand Down
44 changes: 38 additions & 6 deletions pywordfreq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
import importlib.resources
import sys

from . import pywordfreq

PY_VERSION_MAJOR = sys.version_info.major
PY_VERSION_MINOR = sys.version_info.minor


def lazy_full_frequency(
word,
):
pywordfreq.load_dictionary(
importlib.resources.read_binary(
if PY_VERSION_MAJOR >= 3 and PY_VERSION_MINOR >= 11:
with importlib.resources.files(
__package__,
).joinpath(
'word_frequencies.gz',
).open(
'rb',
) as _word_frequencies_binary:
word_frequencies_binary = _word_frequencies_binary.read()
else:
word_frequencies_binary = importlib.resources.read_binary(
package=__package__,
resource='word_frequencies.gz',
)

pywordfreq.load_dictionary(
word_frequencies_binary
)

global full_frequency
Expand All @@ -19,17 +35,31 @@ def lazy_full_frequency(
full_frequency = pywordfreq.full_frequency
partial_frequency = pywordfreq.partial_frequency

return pywordfreq.full_frequency(word)
return pywordfreq.full_frequency(
word
)


def lazy_partial_frequency(
pattern,
):
pywordfreq.load_dictionary(
importlib.resources.read_binary(
if PY_VERSION_MAJOR >= 3 and PY_VERSION_MINOR >= 11:
with importlib.resources.files(
__package__,
).joinpath(
'word_frequencies.gz',
).open(
'rb',
) as _word_frequencies_binary:
word_frequencies_binary = _word_frequencies_binary.read()
else:
word_frequencies_binary = importlib.resources.read_binary(
package=__package__,
resource='word_frequencies.gz',
)

pywordfreq.load_dictionary(
word_frequencies_binary
)

global full_frequency
Expand All @@ -38,7 +68,9 @@ def lazy_partial_frequency(
full_frequency = pywordfreq.full_frequency
partial_frequency = pywordfreq.partial_frequency

return pywordfreq.partial_frequency(pattern)
return pywordfreq.partial_frequency(
pattern
)


full_frequency = lazy_full_frequency
Expand Down

0 comments on commit 43f138f

Please sign in to comment.