Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/label_studio_sdk/label_interface/control_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"videorectangle": "VideoRectangleTag",
"number": "NumberTag",
"datetime": "DateTimeTag",
"hypertext": "HyperTextLabelsTag",
"hypertextlabels": "HyperTextLabelsTag",
"pairwise": "PairwiseTag",
"paragraphlabels": "ParagraphLabelsTag",
"ranker": "RankerTag",
Expand Down Expand Up @@ -503,7 +503,7 @@ def as_tuple(self):
if isinstance(to_name, list):
to_name = ",".join(to_name)

return "|".join([from_name, to_name, type.lower()])
return "|".join([from_name, to_name, tag_type.lower()])


class SpanSelection(BaseModel):
Expand Down Expand Up @@ -888,13 +888,13 @@ def to_json_schema(self):


class HyperTextLabelsValue(SpanSelectionOffsets):
htmllabels: List[str]
hypertextlabels: List[str]


class HyperTextLabelsTag(ControlTag):
""" """
tag: str = "HyperTextLabels"
_label_attr_name: str = "htmllabels"
_label_attr_name: str = "hypertextlabels"
_value_class: Type[HyperTextLabelsValue] = HyperTextLabelsValue


Expand Down Expand Up @@ -934,7 +934,7 @@ class ParagraphLabelsValue(SpanSelectionOffsets):

class ParagraphLabelsTag(ControlTag):
""" """
tag: str = "ParagraphsLabels"
tag: str = "ParagraphLabels"
_label_attr_name: str = "paragraphlabels"
_value_class: Type[ParagraphLabelsValue] = ParagraphLabelsValue

Expand Down
2 changes: 1 addition & 1 deletion tests/custom/test_interface/test_control_tags_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
(OT.TextTag, CT.LabelsTag, { "label": [ c.LABEL1, c.LABEL2 ], "start": 1, "end": 10 }, { "labels": [ c.LABEL1, c.LABEL2 ], "start": 1, "end": 10 }),

## Hypertext labeling
(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 ] }),
(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 ] }),

## Paragraphs labeling
(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 ] } ),
Expand Down
8 changes: 2 additions & 6 deletions tests/custom/test_interface/test_prediction_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,20 +493,16 @@ def test_hypertext_labels_validation(self):
"end": 10,
"startOffset": 0,
"endOffset": 10,
"htmllabels": ["html1"]
"hypertextlabels": ["html1"]
}
}],
"score": 0.8
}
# This test is expected to fail because HyperTextLabels validation is not fully implemented
# We'll skip this test for now
pytest.skip("HyperTextLabels validation not fully implemented in current SDK version")

assert li.validate_prediction(valid_pred) is True

# Invalid - wrong label
invalid_pred = copy.deepcopy(valid_pred)
invalid_pred["result"][0]["value"]["htmllabels"] = ["invalid_html"]
invalid_pred["result"][0]["value"]["hypertextlabels"] = ["invalid_html"]
assert li.validate_prediction(invalid_pred) is False

def test_pairwise_validation(self):
Expand Down
Loading