Skip to content

Support for Oxford English (rebased) - #53

Merged
FortiShield merged 3 commits into
masterfrom
Oxford
Oct 12, 2025
Merged

Support for Oxford English (rebased)#53
FortiShield merged 3 commits into
masterfrom
Oxford

Conversation

@FortiShield

@FortiShield FortiShield commented Oct 12, 2025

Copy link
Copy Markdown
Collaborator

Summary by Sourcery

Add support for an Oxford English dictionary by generating a new en-to-en-OX dictionary file and integrating it throughout the build, test, and CI pipelines

New Features:

  • Introduce en-to-en-OX dictionary support with a new builtin 'en_to_en-OX' option
  • Add Makefile rule and normalize_spelling.sh script to auto-generate the Oxford English dictionary file

Enhancements:

  • Integrate the autogenerated dictionary into sort, trim, and check Makefile targets
  • Clean up tox.ini by consolidating testenv configs and ensuring dictionary checks are included
  • Update tests to recognize the new dictionary and adjust error-duplication logic

CI:

  • Add a GitHub Actions workflow to regenerate the autogenerated dictionary on pull request events

Documentation:

  • Update the manual page to document the 'en_to_en-OX' dictionary option

Summary by CodeRabbit

  • New Features
    • Expanded English spelling corrections with a comprehensive autogenerated dictionary (e.g., colour→color, recognise→recognize, writeable→writable).
  • Documentation
    • Added a generated manual page detailing usage, options, and examples.
  • Tests
    • Updated tests to account for the new dictionary and cross-dictionary validations.
  • CI
    • Introduced an autofix workflow to automatically propose fixes on pull requests.
  • Chores
    • Updated build and test tasks to generate and validate the dictionary, integrating checks into existing workflows.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR introduces automated support for an Oxford English dictionary by generating an “en_to_en-OX” mapping, integrates it into the build and CI pipelines, updates the builtin dictionary configuration, adjusts tests to account for the new file, refines the tox setup, and adds an autofix workflow and regenerated manpage.

Class diagram for builtin dictionary configuration update

classDiagram
    class BuiltinDictionaryConfig {
        +name: str
        +description: str
        +filename: str
        +auto_fix: bool | None
        +enabled: bool | None
        +source_langs: tuple | None
        +target_langs: tuple | None
    }
    BuiltinDictionaryConfig <|-- EnToEnOXConfig
    class EnToEnOXConfig {
        +name = "en_to_en-OX"
        +description = "for corrections from en to en-OX"
        +filename = "_en_to_en-OX_AUTOGENERATED"
        +auto_fix = None
        +enabled = None
        +source_langs = None
        +target_langs = None
    }
Loading

File-Level Changes

Change Details Files
Generate and integrate an Oxford English dictionary in the build
  • Define a GENERATED variable for the new dictionary file
  • Update all and check targets to depend on GENERATED
  • Add a rule invoking normalize_spelling.sh to produce the Oxford dictionary
  • Make sort- and trim-dictionaries also depend on GENERATED
Makefile
tools/normalize_spelling.sh
Update builtin dictionary mapping to include new Oxford variant
  • Rename mapping key and description to en_to_en-OX
  • Set the generated-dict parameters to None to defer to the autogenerated file
codetypo/_codetypo.py
Refine tox.ini to streamline dictionary env and type checking
  • Add and position testenv:dictionaries section once
  • Remove the duplicate dictionaries block
  • Ensure mypy runs in the type env
tox.ini
Adjust tests for the new autogenerated dictionary
  • Include the new file in allowed duplicate sets
  • Modify duplicate-error loop to permit identical fixes
codetypo/tests/test_dictionary.py
Add CI workflow to regenerate autogenerated dictionaries
  • Introduce .github/workflows/autofix.yml job to run make against the GENERATED target
.github/workflows/autofix.yml
Regenerate and include updated manpage
  • Add the new codetypo.1 output generated by help2man
codetypo.1

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 12, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds an autofix GitHub Actions workflow. Extends Makefile to generate a new autogenerated dictionary and wires targets to depend on it. Introduces a large autogenerated dictionary file and updates builtin dictionary references and tests accordingly. Updates British→American mappings and adds a generated manpage. Adjusts tox to run dictionary checks via make.

Changes

Cohort / File(s) Summary
CI Workflow (autofix)
.github/workflows/autofix.yml
New workflow triggers on PR events, checks out repo, runs make to regenerate the autogenerated dictionary, then runs autofix-ci/action to commit fixes.
Build System
Makefile, tox.ini
Adds GENERATED variable and rule to build codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt; updates targets (all, check, sort/trim-dictionaries, pytest) to depend on it; introduces tox env to run make check-dictionaries.
Dictionary Data (updates + new)
codetypo/data/dictionary_en-GB_to_en-US.txt, codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt
Updates and adds several en-GB→en-US mappings; adds large autogenerated en→en-OX dictionary file.
Builtin Dictionary Config
codetypo/_codetypo.py
Replaces builtin reference en-GB_to_en-US with _en_to_en-OX_AUTOGENERATED entry; fields set to None; description updated.
Tests
codetypo/tests/test_dictionary.py
Permits specific duplicate pairs with the new autogenerated dictionary; adjusts duplication check to compare (err, fix) pairs across dictionaries.
Documentation
codetypo.1
Adds generated manpage covering usage, options, and references.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant PR as GitHub PR
  participant GA as GitHub Actions (autofix.ci)
  participant Make as make
  participant Tools as normalize_spelling.sh
  participant Repo as Repo (branch)

  PR->>GA: opened/synchronize/labeled/unlabeled
  GA->>Repo: actions/checkout@v5 (no credentials)
  GA->>Make: make (generate autogenerated dictionary)
  Make->>Tools: run normalization script
  Tools-->>Make: output dictionary_en_to_en-OX_AUTOGENERATED.txt
  Make-->>GA: build artifacts updated
  GA->>Repo: autofix-ci/action (commit changes)
  Repo-->>PR: updated PR with regenerated files
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • NxPKG
  • khulnasoft-bot

Poem

I nibbled words and flipped their hue,
From centre’s core to center’s cue.
Make taps a script—thump, thump—so neat,
The PR garden prunes its wheat.
Dictionaries bloom in rows,
A rabbit stamps, “Autofix grows!” 🥕

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Oxford

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between abc54f9 and ed67ffb.

📒 Files selected for processing (8)
  • .github/workflows/autofix.yml (1 hunks)
  • Makefile (3 hunks)
  • codetypo.1 (1 hunks)
  • codetypo/_codetypo.py (1 hunks)
  • codetypo/data/dictionary_en-GB_to_en-US.txt (9 hunks)
  • codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt (1 hunks)
  • codetypo/tests/test_dictionary.py (2 hunks)
  • tox.ini (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codiumai-pr-agent-free

codiumai-pr-agent-free Bot commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `Makefile:7` </location>
<code_context>
+GENERATED := codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt

-check: check-dictionaries check-dist pytest ruff
+all: $(GENERATED) check-dictionaries codespell.1
+
+check: $(GENERATED) check-dictionaries check-dist pytest ruff
</code_context>

<issue_to_address>
**issue (typo):** Check if 'codespell.1' is intended or a typo for 'codetypo.1'.

'codespell.1' may be a typo and could lead to confusion or build issues if not corrected.

```suggestion
all: $(GENERATED) check-dictionaries codetypo.1
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread Makefile Outdated
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: fortishield <161459699+FortiShield@users.noreply.github.com>
@codiumai-pr-agent-free

codiumai-pr-agent-free Bot commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Consider keeping both dictionary options

Instead of replacing the en-GB_to_en-US dictionary with the new en_to_en-OX
dictionary, both should be kept. This would provide users with the flexibility
to enforce either US or Oxford English spelling.

Examples:

codetypo/_codetypo.py [128-135]
        "en_to_en-OX",
        "for corrections from en to en-OX",
        "_en_to_en-OX_AUTOGENERATED",
        None,
        None,
        None,
        None,
    ),

Solution Walkthrough:

Before:

# codetypo/_codetypo.py

_builtin_dictionaries = (
    # ... other dictionaries
    (
        "en_to_en-OX",
        "for corrections from en to en-OX",
        "_en_to_en-OX_AUTOGENERATED",
        None,
        None,
        None,
        None,
    ),
)

After:

# codetypo/_codetypo.py

_builtin_dictionaries = (
    # ... other dictionaries
    (
        "en-GB_to_en-US",
        "for corrections from en-GB to en-US",
        "_en-GB_to_en-US",
        True,
        True,
        ("en_GB",),
        ("en_US",),
    ),
    (
        "en_to_en-OX",
        "for corrections from en to en-OX",
        "_en_to_en-OX_AUTOGENERATED",
        None,
        None,
        None,
        None,
    ),
)
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that the PR removes the existing en-GB_to_en-US dictionary option, which is a functional regression, and proposes retaining both dictionaries to enhance user flexibility.

High
Possible issue
Fix incorrect dependency in Makefile
Suggestion Impact:The commit directly implemented the suggestion by changing the dependency in the Makefile's all target from codespell.1 to codetypo.1, exactly as suggested

code diff:

-all: $(GENERATED) check-dictionaries codespell.1
+all: $(GENERATED) check-dictionaries codetypo.1

In the Makefile, correct the all target's dependency from codespell.1 to
codetypo.1 to prevent the build from failing.

Makefile [7]

-all: $(GENERATED) check-dictionaries codespell.1
+all: $(GENERATED) check-dictionaries codetypo.1

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a typo in the all target of the Makefile which would cause the make all command to fail, thus breaking a core part of the build process.

High
General
Improve assertion message for clarity

Update the assertion message in test_dictionary_looping to include the
conflicting corrections when a duplicate error word is found, improving
debuggability.

codetypo/tests/test_dictionary.py [338-342]

-for err in this_err_dict:
-    assert err not in other_err_dict, (
+for err, fix in this_err_dict.items():
+    assert err not in other_err_dict or fix == other_err_dict[err], (
         f"error {err!r} in dictionary {short_fname} "
-        f"already exists in dictionary {other_fname}"
+        f"already exists in dictionary {other_fname} with a different correction "
+        f"('{other_err_dict[err]}' vs '{fix}')"
     )

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that the assertion message in the new test logic is misleading and would make debugging failures more difficult, proposing a much clearer message.

Low
  • Update

@qodo-code-review

qodo-code-review Bot commented Oct 12, 2025

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
The core generation script is missing

The tools/normalize_spelling.sh script, which is responsible for generating the
Oxford English dictionary, is missing from the PR. This prevents review of the
core logic and makes the PR incomplete.

Examples:

Makefile [11-12]
$(GENERATED): codetypo/data/dictionary_en-GB_to_en-US.txt ./tools/normalize_spelling.sh
	./tools/normalize_spelling.sh codetypo/data/dictionary_en-GB_to_en-US.txt > codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt
tools/normalize_spelling.sh [1]
#!/usr/bin/env bash

Solution Walkthrough:

Before:

# Makefile
GENERATED := codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt

$(GENERATED): codetypo/data/dictionary_en-GB_to_en-US.txt ./tools/normalize_spelling.sh
	./tools/normalize_spelling.sh ... > $(GENERATED)

# tools/normalize_spelling.sh
# (File content is missing from the PR diff)

After:

# Makefile
GENERATED := codetypo/data/dictionary_en_to_en-OX_AUTOGENERATED.txt

$(GENERATED): codetypo/data/dictionary_en-GB_to_en-US.txt ./tools/normalize_spelling.sh
	./tools/normalize_spelling.sh ... > $(GENERATED)

# tools/normalize_spelling.sh
#!/bin/bash
# This script reverses the key-value pairs in a dictionary file.
# It reads from the input file specified as the first argument.
# For each line "key->value", it outputs "value->key".
awk -F'->' '{print $2 "->" $1}' "$1"
Suggestion importance[1-10]: 10

__

Why: This suggestion correctly identifies a critical omission; the tools/normalize_spelling.sh script, which implements the core logic of the PR, is missing, making a proper review impossible.

High
Possible issue
Grant write permissions for autofix workflow
Suggestion Impact:The commit updated the autofix workflow permissions from read to write for contents, enabling push capability as suggested.

code diff:

 permissions:
-  contents: read
+  contents: write

Change the contents permission in the autofix.yml workflow from read to write to
allow the autofix-ci/action to push changes.

.github/workflows/autofix.yml [7-8]

 permissions:
-  contents: read
+  contents: write

[Suggestion processed]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that the new autofix workflow will fail because it lacks the necessary contents: write permission to push generated file changes.

High
Fix typo in Makefile target dependency
Suggestion Impact:The commit updated the Makefile 'all' target to depend on codetypo.1 instead of codespell.1, exactly as suggested.

code diff:

-all: $(GENERATED) check-dictionaries codespell.1
+all: $(GENERATED) check-dictionaries codetypo.1

In the Makefile, correct the typo in the all target's dependency from
codespell.1 to codetypo.1.

Makefile [7]

-all: $(GENERATED) check-dictionaries codespell.1
+all: $(GENERATED) check-dictionaries codetypo.1

[Suggestion processed]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a typo codespell.1 instead of codetypo.1 in the all target's dependencies, which is a regression that would prevent the man page from being built.

Medium
  • More

Comment thread .github/workflows/autofix.yml Outdated
Comment on lines +7 to +8
permissions:
contents: read

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Grant write permissions for autofix workflow

Suggested change
permissions:
contents: read
permissions:
contents: write

Comment thread .github/workflows/autofix.yml Outdated
Co-authored-by: codiumai-pr-agent-free[bot] <138128286+codiumai-pr-agent-free[bot]@users.noreply.github.com>
Signed-off-by: fortishield <161459699+FortiShield@users.noreply.github.com>
@FortiShield
FortiShield merged commit b448de0 into master Oct 12, 2025
3 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant