Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
- name: Build package
run: |
python -m pip install twine build
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.11
python-version: "3.12"
- name: set PY
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: actions/cache@v3
Expand All @@ -40,10 +40,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.9
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ used the pyenchant package and its default dictionary. The pyenchant package
requires an underlying C library, which is not available on all platforms.
PySpellChecker is a pure Python package and works on all platforms with no
additional dependencies.

The `--bibtex` option adds words from citation keys to the dictionary and
requires bibtexparser 2.x.
14 changes: 6 additions & 8 deletions comment_spell_check/utils/bibtex_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ def add_bibtex(spell: spellchecker.SpellChecker, filename: str):

word_list = []

with open(filename, "rt", encoding="utf-8") as biblatex_file:
bib_database = bibtexparser.load(biblatex_file)
bib_database = bibtexparser.parse_file(filename)
for entry in bib_database.entries:
words = split_bibtex_name(entry.key)
word_list.extend(words)

for k in bib_database.get_entry_dict().keys():
words = split_bibtex_name(k)
word_list.extend(words)

logger.info("Words: %s", word_list)
spell.word_frequency.load_words(word_list)
logger.info("Words: %s", word_list)
spell.word_frequency.load_words(word_list)
41 changes: 7 additions & 34 deletions conda-env.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/osx-64/ca-certificates-2019.9.11-hecc5488_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/jpeg-9b-he5867d9_2.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libcxxabi-4.0.1-hcfea43d_1.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/xz-5.2.4-h1de35cc_4.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/zlib-1.2.11-h1de35cc_3.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libcxx-4.0.1-hcfea43d_1.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libpng-1.6.37-ha441bb4_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/openssl-1.1.1c-h01d97ff_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/tk-8.6.8-ha441bb4_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/zstd-1.3.7-h5bba6e5_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libffi-3.2.1-h475c297_4.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libtiff-4.0.10-hcb84e12_2.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/llvm-openmp-8.0.1-h770b8ee_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/ncurses-6.1-h0a44026_1.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/libedit-3.1.20181209-hb402a30_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libgfortran-4.0.0-2.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/readline-7.0-h1de35cc_5.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libopenblas-0.3.7-h4bb4525_1.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/sqlite-3.29.0-ha441bb4_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libblas-3.8.0-12_openblas.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/python-3.7.4-h359304d_1.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/certifi-2019.9.11-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/libcblas-3.8.0-12_openblas.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/liblapack-3.8.0-12_openblas.tar.bz2
https://conda.anaconda.org/simpleitk/label/dev/osx-64/simpleitk-1.2rc1-py37h0a44026_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/numpy-1.17.2-py37h6b0580a_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/setuptools-41.0.1-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/osx-64/itk-5.0.1-py37_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/wheel-0.33.4-py37_0.tar.bz2
https://repo.anaconda.com/pkgs/main/osx-64/pip-19.2.2-py37_0.tar.bz2
# Create the environment with:
# conda create --name <env> --file <this file> --override-channels \
# --channel conda-forge --platform osx-64
# Then run this in the activated environment:
# python -m pip install itk SimpleITK
python=3.12
pip
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ authors = [
description = "A script to automatically spell checks comments of a codebase."
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.8"
requires-python = ">=3.12"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment_parser
pyspellchecker
bibtexparser
bibtexparser>=2.0,<3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a roundabout way to say bibtexparser~=2.0 which means any version from the 2.x family. Was there a reason for specifying it this way?

requests
14 changes: 14 additions & 0 deletions tests/test_comment_spell_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

import unittest
import subprocess
from pathlib import Path

from spellchecker import SpellChecker

from comment_spell_check.utils.bibtex_loader import add_bibtex


class TestCommentSpellCheck(unittest.TestCase):
Expand Down Expand Up @@ -105,6 +110,15 @@ def test_bibtex(self):
)
self.assertEqual(runresult.returncode, 0, runresult.stdout)

def test_bibtex_citation_keys_added_to_dictionary(self):
spell = SpellChecker()
citation_words = {"lowekamp", "yaniv", "simpleitk", "yushkevich"}
self.assertEqual(spell.unknown(citation_words), citation_words)
bibtex_file = Path(__file__).with_name("itk.bib")
add_bibtex(spell, str(bibtex_file))

self.assertEqual(spell.unknown(citation_words), set())

def test_url(self):
"""URL test"""
url = (
Expand Down
Loading