- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2
          feat: normalize/sanitize Anwendungsfall.beschreibung
          #176
        
          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
based on #176 (no depedency - just to avoid merge conflicts)
…et) (#177) * feat: introduce function to parse `Kommunikation_von` (w/o using it yet) based on #176 (no depedency - just to avoid merge conflicts) * fix some more edge cases --------- Co-authored-by: Konstantin <[email protected]>
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 functionality to normalize and sanitize the Anwendungsfall.beschreibung field by removing line breaks and hyphens according to specific rules.
- Implements a new utility function remove_linebreaks_and_hyphensthat handles whitespace normalization and hyphen removal
- Adds comprehensive unit tests covering various edge cases including trailing whitespace, line breaks, and hyphen-linebreak combinations
- Updates the AHB reader to use the new normalization function for the beschreibungattribute
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description | 
|---|---|
| src/fundamend/utils.py | Adds the new normalization function with replacement rules and exports it | 
| unittests/test_utils.py | Provides comprehensive test coverage for the normalization function | 
| src/fundamend/reader/ahbreader.py | Integrates the new normalization function into the Anwendungsfall creation | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| def lstrip(prefix: str, text: str) -> str: | ||
| """Strip the given prefix from the given text. If the text does not start with the prefix, return the text as is. | ||
| Args: | ||
| prefix: The prefix to strip. | ||
| text: The text to strip the prefix from. | ||
| Returns: | ||
| The text with the prefix stripped. | ||
| """ | ||
| if text.startswith(prefix): | ||
| return text[len(prefix) :] | ||
| return text | ||
|  | ||
|  | ||
| def rstrip(text: str, suffix: str) -> str: | ||
| """Strip the given suffix from the given text. If the text does not end with the suffix, return the text as is. | ||
| Args: | ||
| text: The text to strip the suffix from. | ||
| suffix: The suffix to strip. | ||
| Returns: | ||
| The text with the suffix stripped. | ||
| """ | ||
| if text.endswith(suffix): | ||
| return text[: -len(suffix)] | ||
| return text | ||
|  | ||
|  | ||
| def strip(prefix: str, text: str, suffix: str) -> str: | ||
| """Strip the given prefix and suffix from the given text. If the text does not start with the prefix or does not | ||
| end with the suffix, return the text as is. | ||
| Args: | ||
| prefix: The prefix to strip. | ||
| text: The text to strip the prefix from. | ||
| suffix: The suffix to strip. | ||
| Returns: | ||
| The text with the prefix and suffix stripped. | ||
| """ | ||
| return lstrip(prefix, rstrip(text, suffix)) | 
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.
wieso erfinden wir die strip methoden nochmal neu?
https://docs.python.org/3/library/stdtypes.html#str.lstrip
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.
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.
mein kommentar ist leider out of scope, bin da nur drüber gestolpert.
Co-authored-by: Copilot <[email protected]>
fixes #172