#328 - Remove annotations in a specified range#329
Conversation
- added functions for removing annoations from cas - cut_sofa_string_to_range - remove_annotations_in_range - added tests
|
Thanks for the PR. "Normally" (i.e. in particular in Java UIMA), the sofa is considered to be immutable once set. Have you considered generating a new CAS that contains only the cut-out section instead of doing an in-place modification? |
|
I didn't expect such a quick response, thanks :) |
There was a problem hiding this comment.
Pull Request Overview
This PR adds two convenience methods to the Cas class for managing annotations based on their position in the sofa string: cut_sofa_string_to_range and remove_in_range.
Key changes:
cut_sofa_string_to_range: Cuts the sofa string to a specified range and removes/adjusts annotations accordinglyremove_in_range: Removes annotations within a specified range, optionally filtered by type- Comprehensive test coverage for both methods with different scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| cassis/cas.py | Adds two new methods: cut_sofa_string_to_range for cutting sofa string with annotation adjustment, and remove_in_range for removing annotations in a range |
| tests/test_cas.py | Adds four test functions covering different scenarios for both new methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I agree with most suggestions, with the exception of the issue iteration/remove (384-398). But I am, again, unsure how to proceed from here on :) |
|
Thanks again :) Same as with the other PR:
This change is a tricky one because you can have annotations that are transitively referenced through a feature of an indexed feature structure, not that themselves are not on the index. That means if you use only select_all(), you would not find them. You would have to use |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@zesch Do you have an opinion on this?
|
I would vote for removing it entirely. |
- Fixed condition
- Defensive copy of list before removal - Remove debug printf
- Improve test assertion - Rename parameters for consistency
- Improve test assertion - Rename parameters for consistency - Use overlap predicate in test - Fixed docstring
- Improve test
- Additional testing - Added warning to the cut_sofa_string_to_range function.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Generate proper error when there is no sofa string - Fix signature - Remove duplicate variable declaration - Expanded test and fixed bug
- Another guard against unset sofa string
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Improve tests - Improve handling of non-annotation types
|
@dmnc-grdnr ok, I have taken some executive decisions to wrap this up now - otherwise we'll ping pong this forever. Probably I should generally be more proactive of taking over and finishing up PRs. Thanks for your contribution! |
This PR adds the following convenience functions to the cas object:
crop_sofa_string-> replaces the sofa string with a cutout of the original as specified by the index range and removes all annotations in the cas that are outside of that specified rangeremove_annotations_in_range-> removes all annoations (of one specified type) inside of the specified index range of the sofa stringThe methods can be called on any cas object directly.
Tests for each function was added to test_cas.py