Skip to content

Conversation

@hf-kklein
Copy link
Contributor

fixes #172

hf-kklein pushed a commit that referenced this pull request Sep 22, 2025
based on #176 (no depedency - just to avoid merge conflicts)
hf-kklein added a commit that referenced this pull request Oct 1, 2025
…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]>
@hf-krechan hf-krechan requested a review from Copilot October 15, 2025 08:13
Copy link
Contributor

Copilot AI left a 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_hyphens that 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 beschreibung attribute

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.

Comment on lines 6 to 48
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@hf-krechan hf-krechan left a 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.

@hf-kklein hf-kklein enabled auto-merge (squash) October 15, 2025 08:44
@hf-kklein hf-kklein disabled auto-merge October 15, 2025 09:01
@hf-kklein hf-kklein enabled auto-merge (squash) October 15, 2025 09:10
@hf-kklein hf-kklein merged commit ca3b885 into main Oct 15, 2025
21 checks passed
@hf-kklein hf-kklein deleted the linebreaks branch October 15, 2025 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Names of Prüfidentifikatoren

4 participants