-
-
Notifications
You must be signed in to change notification settings - Fork 294
Generate regex with local LLM #612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a new menu option to extract regex patterns from text using Windows AI LanguageModel. Also includes code style improvements and modernizations in language detection logic. No breaking changes to existing features.
Separated character, numeric, file, and OCR utilities into their own classes for improved modularity and maintainability. Updated usages throughout EditTextWindow and related files. Improved error handling and WPF compatibility.
Enhanced regex pattern detection and explanation display for better usability and clarity.
There was a problem hiding this 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 "Extract RegEx" feature that uses Windows AI local LLM to generate regular expression patterns from text descriptions. It also refactors code by extracting utility methods from EditTextWindow into dedicated utility classes for better maintainability.
Changes:
- Added new
WindowsAiUtilities.ExtractRegex()method that generates regex patterns using local AI - Created three new utility classes (
NumericUtilities,CharacterUtilities,IoUtilities) and moved helper methods from EditTextWindow to improve code organization - Added auto-detection feature in FindAndReplaceWindow that automatically enables regex mode when patterns start with
^and end with$
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| Text-Grab/Views/EditTextWindow.xaml | Added new "Extract RegEx" menu item to the AI submenu |
| Text-Grab/Views/EditTextWindow.xaml.cs | Implemented ExtractRegexMenuItem_Click handler; refactored helper methods out to utility classes; minor code cleanup (null checks, namespace simplifications) |
| Text-Grab/Utilities/WindowsAiUtilities.cs | Added ExtractRegex and CleanRegexResult methods for AI-powered regex generation; improved code formatting consistency |
| Text-Grab/Utilities/NumericUtilities.cs | New utility class containing numeric helper methods (CalculateMedian, FormatNumber, AreClose) moved from EditTextWindow |
| Text-Grab/Utilities/CharacterUtilities.cs | New utility class containing character analysis methods (GetUnicodeCategory, GetCharacterDetailsText, HTML entity helpers) moved from EditTextWindow |
| Text-Grab/Utilities/IoUtilities.cs | Added ListFilesFoldersInDirectory method moved from EditTextWindow |
| Text-Grab/Utilities/OcrUtilities.cs | Added OcrFile method moved from EditTextWindow |
| Text-Grab/Utilities/StringMethods.cs | Added CountMatches and CountRegexMatches methods moved from EditTextWindow |
| Text-Grab/Utilities/WindowUtilities.cs | Added GetScrollViewer method moved from EditTextWindow |
| Text-Grab/Controls/FindAndReplaceWindow.xaml.cs | Added auto-detection for regex patterns with anchors (^$) that automatically enables regex mode |
Refactor for consistency, readability, and modern C# usage.
Expanded test coverage for CleanRegexResult, added analysis report for filtering bug, made method public, and updated test dependencies.
Refined the prompt for generating regex patterns to be more direct and concise, emphasizing the return of only the regex pattern.
No description provided.