Skip to content

Commit 5a89968

Browse files
authored
fix: UTC-520: Fixed HyperTextLabelsTag and ParagraphLabelsTag tag validation (#741)
1 parent f1b9ad9 commit 5a89968

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

src/label_studio_sdk/label_interface/control_tags.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"videorectangle": "VideoRectangleTag",
3434
"number": "NumberTag",
3535
"datetime": "DateTimeTag",
36-
"hypertext": "HyperTextLabelsTag",
36+
"hypertextlabels": "HyperTextLabelsTag",
3737
"pairwise": "PairwiseTag",
3838
"paragraphlabels": "ParagraphLabelsTag",
3939
"ranker": "RankerTag",
@@ -503,7 +503,7 @@ def as_tuple(self):
503503
if isinstance(to_name, list):
504504
to_name = ",".join(to_name)
505505

506-
return "|".join([from_name, to_name, type.lower()])
506+
return "|".join([from_name, to_name, tag_type.lower()])
507507

508508

509509
class SpanSelection(BaseModel):
@@ -888,13 +888,13 @@ def to_json_schema(self):
888888

889889

890890
class HyperTextLabelsValue(SpanSelectionOffsets):
891-
htmllabels: List[str]
891+
hypertextlabels: List[str]
892892

893893

894894
class HyperTextLabelsTag(ControlTag):
895895
""" """
896896
tag: str = "HyperTextLabels"
897-
_label_attr_name: str = "htmllabels"
897+
_label_attr_name: str = "hypertextlabels"
898898
_value_class: Type[HyperTextLabelsValue] = HyperTextLabelsValue
899899

900900

@@ -934,7 +934,7 @@ class ParagraphLabelsValue(SpanSelectionOffsets):
934934

935935
class ParagraphLabelsTag(ControlTag):
936936
""" """
937-
tag: str = "ParagraphsLabels"
937+
tag: str = "ParagraphLabels"
938938
_label_attr_name: str = "paragraphlabels"
939939
_value_class: Type[ParagraphLabelsValue] = ParagraphLabelsValue
940940

tests/custom/test_interface/test_control_tags_label.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
(OT.TextTag, CT.LabelsTag, { "label": [ c.LABEL1, c.LABEL2 ], "start": 1, "end": 10 }, { "labels": [ c.LABEL1, c.LABEL2 ], "start": 1, "end": 10 }),
4848

4949
## Hypertext labeling
50-
(OT.HyperTextTag, CT.HyperTextLabelsTag, { "start": 1, "end": 10, "startOffset": 10, "endOffset": 10, "label": c.LABEL1 }, { "start": 1, "end": 10, "startOffset": 10, "endOffset": 10, "htmllabels": [ c.LABEL1 ] }),
50+
(OT.HyperTextTag, CT.HyperTextLabelsTag, { "start": 1, "end": 10, "startOffset": 10, "endOffset": 10, "label": c.LABEL1 }, { "start": 1, "end": 10, "startOffset": 10, "endOffset": 10, "hypertextlabels": [ c.LABEL1 ] }),
5151

5252
## Paragraphs labeling
5353
(OT.ParagraphsTag, CT.ParagraphLabelsTag, { "start": 0, "end": 0, "startOffset": 10, "endOffset": 10, "label": [ c.LABEL1 ] }, { "start": 0, "end": 0, "startOffset": 10, "endOffset": 10, "paragraphlabels": [ c.LABEL1 ] } ),

tests/custom/test_interface/test_prediction_validation.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,20 +493,16 @@ def test_hypertext_labels_validation(self):
493493
"end": 10,
494494
"startOffset": 0,
495495
"endOffset": 10,
496-
"htmllabels": ["html1"]
496+
"hypertextlabels": ["html1"]
497497
}
498498
}],
499499
"score": 0.8
500500
}
501-
# This test is expected to fail because HyperTextLabels validation is not fully implemented
502-
# We'll skip this test for now
503-
pytest.skip("HyperTextLabels validation not fully implemented in current SDK version")
504-
505501
assert li.validate_prediction(valid_pred) is True
506502

507503
# Invalid - wrong label
508504
invalid_pred = copy.deepcopy(valid_pred)
509-
invalid_pred["result"][0]["value"]["htmllabels"] = ["invalid_html"]
505+
invalid_pred["result"][0]["value"]["hypertextlabels"] = ["invalid_html"]
510506
assert li.validate_prediction(invalid_pred) is False
511507

512508
def test_pairwise_validation(self):

0 commit comments

Comments
 (0)