Skip to main content
Version: 25.4

snorkelflow.client.annotations.add_annotation

snorkelflow.client.annotations.add_annotation(node, x_uid, label, metadata=None)

Add an annotation for a document or a span. The label for the annotation must be in the appropriate format expected by the model node specified by the “node” parameter. To learn more about label formats, see Format for ground truth interaction in the SDK.

Examples

>>> # Add a positive label for a document
>>> sf.add_annotation(node, "doc::1", "POS", metadata={"created by": "sdk"})
{
'annotation_uid': 12345,
'source': {
'source_uid': 1,
'source_type': 'user',
'source_name': 'my-name',
'user_uid': 0,
'metadata': {"created by": "sdk"}
},
'workspace_uid': 1
}

Parameters

NameTypeDefaultInfo
nodeintUID of the node.
x_uidstrUID of the document or span to be annotated.
labelAnyThe label for annotation (“POS”, “NEG”, etc). The format of the label depends on the configuration of the model node specified by the “node” parameter.
metadataOptional[Dict]NoneAny metadata that we want to save for the annotation.

Return type

List[Dict[str, any]