From 4d51aea2d04209db0ac0d4408c4616352da6f3cc Mon Sep 17 00:00:00 2001 From: tentse Date: Wed, 29 Oct 2025 16:05:40 +0530 Subject: [PATCH 1/2] Updated the alignment check method to include target_annotation_id as a parameter for improved functionality in AlignedPechaJsonSerializer. --- src/openpecha/pecha/serializers/json.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openpecha/pecha/serializers/json.py b/src/openpecha/pecha/serializers/json.py index 570ea470..f32dfd8e 100644 --- a/src/openpecha/pecha/serializers/json.py +++ b/src/openpecha/pecha/serializers/json.py @@ -306,7 +306,7 @@ def serialize_aligned_pechas_transformed_annotations(self): target_annotation_id, source_annotation_id = self.get_aligned_to_annotation_id(self.source_annotations) - is_target_annnotation_is_alignement = self._check_if_target_annotation_is_alignment_(self.target_annotations) + is_target_annnotation_is_alignement = self._check_if_target_annotation_is_alignment_(self.target_annotations, target_annotation_id) target_alignment_annotation = None if is_target_annnotation_is_alignement: @@ -350,8 +350,8 @@ def _get_target_segmentation_annotation_id_(self, target_annotations: list[dict] raise ValueError("No segmentation annotation found") - def _check_if_target_annotation_is_alignment_(self, target_annotations: list[dict]) -> bool: - for target_annotation in target_annotations: + def _check_if_target_annotation_is_alignment_(self, target_annotations: list[dict], target_annotation_id: str) -> bool: + for target_annotation in target_annotations and target_annotation['id'] == target_annotation_id: if (target_annotation['type'] == 'alignment'): return True return False \ No newline at end of file From a8b1ce9e0ad290f8daa64528b3930090dc83b59b Mon Sep 17 00:00:00 2001 From: tentse Date: Wed, 29 Oct 2025 17:18:54 +0530 Subject: [PATCH 2/2] Refined alignment check logic in AlignedPechaJsonSerializer to ensure correct evaluation of target annotations by adjusting the conditional statement. --- src/openpecha/pecha/serializers/json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openpecha/pecha/serializers/json.py b/src/openpecha/pecha/serializers/json.py index f32dfd8e..6ca7f3fb 100644 --- a/src/openpecha/pecha/serializers/json.py +++ b/src/openpecha/pecha/serializers/json.py @@ -351,7 +351,7 @@ def _get_target_segmentation_annotation_id_(self, target_annotations: list[dict] def _check_if_target_annotation_is_alignment_(self, target_annotations: list[dict], target_annotation_id: str) -> bool: - for target_annotation in target_annotations and target_annotation['id'] == target_annotation_id: - if (target_annotation['type'] == 'alignment'): + for target_annotation in target_annotations: + if (target_annotation['type'] == 'alignment' and target_annotation['id'] == target_annotation_id): return True return False \ No newline at end of file