feat (server): new method to check regex regions of a text#144
Merged
mdevolde merged 1 commit intojxmorris12:masterfrom Dec 18, 2025
Merged
feat (server): new method to check regex regions of a text#144mdevolde merged 1 commit intojxmorris12:masterfrom
mdevolde merged 1 commit intojxmorris12:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
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_regionsmethod 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.
db3601b to
30f0802
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
check_matching_regionsmethod inlanguage_tool_python.server.LanguageToolScreenshots (if appropriate):
Not applicable.
How has this been tested?
Creation of a new test, and applied old tests.
Resources
Not applicable.
Types of changes
Checklist