Skip to content

Conversation

@mdevolde
Copy link
Collaborator

feat (server): new method to check regex regions of a text

Why the pull request was made

Added a feature that allows verification to be applied only to areas defined by a regex in a text.
Linked issue: #69

Summary of changes

  • Added a check_matching_regions method in language_tool_python.server.LanguageTool
  • Added linked test

Screenshots (if appropriate):

Not applicable.

How has this been tested?

Creation of a new test, and applied old tests.

Resources

Not applicable.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactor / code style update (non-breaking change that improves code structure or readability)
  • Tests / CI improvement (adding or updating tests or CI configuration only)
  • Other (please describe):

Checklist

  • Followed the project's contributing guidelines.
  • Updated any relevant tests.
  • Updated any relevant documentation.
  • Added comments to your code where necessary.
  • Formatted your code, run the linters, checked types and tests.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new feature to allow selective grammar checking of text regions defined by regular expressions. The implementation adds a check_matching_regions method to the LanguageTool class that enables verification to be applied only to specific portions of text matching a given regex pattern.

Key changes:

  • New check_matching_regions method that accepts text, a regex pattern, and optional regex flags
  • Proper offset adjustment to ensure Match objects can be applied to the original text
  • Test coverage with special characters (emojis) to verify correct offset handling

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
language_tool_python/server.py Adds the check_matching_regions method with regex-based region matching and offset adjustment logic
tests/test_match.py Adds comprehensive test case for the new method, including handling of 4-byte UTF-8 characters
coverage-badge.svg Updates coverage percentage from 77.48% to 77.67% reflecting new code additions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdevolde mdevolde force-pushed the feature/check_with_regex branch from db3601b to 30f0802 Compare December 18, 2025 18:08
@mdevolde mdevolde merged commit 85521c4 into jxmorris12:master Dec 18, 2025
8 checks passed
@mdevolde mdevolde deleted the feature/check_with_regex branch December 18, 2025 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant