⚡️Enhance segmentation regex patterns#197
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates email processing in melusine/processors.py by refining segmentation header detection (via regex construction) and expanding greetings detection, with additional tests to cover new/edge cases.
Changes:
- Refactors segmentation regex construction by splitting header keywords into mandatory vs optional groups and rebuilding the meta-block matching logic.
- Expands
GREETINGSpatterns to detect additional French closing formulas. - Adds/extends test cases for segmentation and greetings tagging behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
melusine/processors.py |
Refactors segmentation regex assembly and adds new greetings regex patterns. |
tests/processors/test_processors.py |
Adds additional segmentation test cases covering tricky “false positive” and header formatting scenarios. |
tests/processors/test_content_refined_tagger.py |
Extends greetings-related split/tag test cases to cover new closing formulas. |
Comments suppressed due to low confidence (2)
melusine/processors.py:445
- The comment says “Match everything until the end of the line”, but
tolerant_line_start = r"^.{,5}"actually matches up to 5 characters at the start of a line (to tolerate prefixes like "> ", bullets, etc.). Please update the comment to reflect what the regex does so future edits don’t accidentally break the intended behavior.
# Match everything until the end of the line.
tolerant_line_start = r"^.{,5}"
semicolon_pattern = r" ?\n? ?: *\n?"
tests/processors/test_processors.py:203
test_segmenter_2duplicates the existingtest_segmenterstructure (same assertions/loop) and has a very generic docstring ("Test"). To keep the test suite maintainable, consider merging these new cases into the existingtest_segmenterparametrization (or at least rename this test to a more specific name and use the standard docstring used elsewhere in this file).
def test_segmenter_2(input_text, expected_messages):
"""Test"""
segmenter = Segmenter()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Enhance segmentation and greetings detection in the
melusine/processors.pymodule.The segmentation regex construction is now "slighlty" more readable.
Improvements to segmentation logic:
De,Cc,Copie,Attachments,Objet, etc.Testing improvements: