-
Notifications
You must be signed in to change notification settings - Fork 74
minor bug fixes #163
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
base: master
Are you sure you want to change the base?
minor bug fixes #163
Conversation
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 pull request addresses character-based IoU calculation issues in span matching evaluation by fixing an off-by-one error and adjusting the matching threshold for more flexible span matching.
- Fixed off-by-one error in character span calculation by removing unnecessary
+ 1in range calls for both annotation and prediction end indices - Reduced the default IoU threshold from 0.9 to 0.75 to allow more flexibility in span matching
- Added comprehensive tests to verify the fix for split entity scenarios and exact matches
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| presidio_evaluator/evaluation/span_evaluator.py | Updated IoU threshold default to 0.75 and fixed off-by-one error in character-based IoU calculations by making end indices properly exclusive |
| tests/test_span_evaluator.py | Added two new test cases to verify character-based IoU calculations work correctly for split entities and exact matches |
| presidio_evaluator/evaluation/scorers.py | Removed obsolete scoring pipeline code that is no longer needed |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| generic_entities: Optional[List[str]] = None, | ||
| skip_words: Optional[List] = None, | ||
| iou_threshold: float = 0.9, | ||
| iou_threshold: float = 0.75, |
Copilot
AI
Dec 7, 2025
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.
The documentation comment at line 35 states the default iou_threshold is 0.5, but the actual default has been changed to 0.75. The documentation should be updated to reflect this change:
:param iou_threshold: Minimum Intersection over Union (IoU) threshold for considering spans as matching.
Value between 0 and 1, where higher values require more overlap (default: 0.75)
This pull request updates the evaluation logic for span matching, focusing on improving the accuracy of character-based IoU calculations and adjusting the threshold for matches. It also adds new tests to ensure correct behavior, especially for split entities. The most important changes are grouped below:
Evaluation Logic Improvements
iou_thresholdinSpanEvaluatorfrom0.9to0.75to allow more flexibility in span matching._calculate_combined_iouby removing the unnecessary+ 1in therangecalls for both annotation and prediction spans. This ensures that character indices are properly exclusive at the end, improving the accuracy of IoU calculations. [1] [2]Testing Enhancements
test_span_evaluator.py:test_calculate_combined_iou_char_based_split_entityverifies that split predictions covering an annotation result in an IoU of 1.0, confirming the off-by-one bug is fixed.test_calculate_combined_iou_char_based_exact_matchchecks that exact matches yield an IoU of 1.0, ensuring no regression in the basic matching logic.