flair.data._PartOfSentence#
- class flair.data._PartOfSentence(sentence)View on GitHub#
Bases:
DataPoint
,ABC
- __init__(sentence)View on GitHub#
Methods
__init__
(sentence)add_label
(typename, value[, score])Adds a label to the
DataPoint
by internally creating aLabel
object.add_metadata
(key, value)clear_embeddings
([embedding_names])get_each_embedding
([embedding_names])get_embedding
([names])get_label
([label_type, zero_tag_value])get_labels
([typename])Returns all labels of this datapoint belonging to a specific annotation layer.
get_metadata
(key)has_label
(type)has_metadata
(key)remove_labels
(typename)set_embedding
(name, vector)set_label
(typename, value[, score])to
(device[, pin_memory])Attributes
embedding
end_position
labels
score
start_position
tag
text
unlabeled_identifier
- add_label(typename, value, score=1.0, **metadata)View on GitHub#
Adds a label to the
DataPoint
by internally creating aLabel
object.- Parameters:
typename (
str
) – A string that identifies the layer of annotation, such as “ner” for named entity labels or “sentiment” for sentiment labelsvalue (
str
) – A string that sets the value of the label.score (
float
) – Optional value setting the confidence level of the label (between 0 and 1). If not set, a default confidence of 1 is used.**metadata – Additional metadata information.
- Returns:
A pointer to itself (DataPoint object, now with an added label).
- set_label(typename, value, score=1.0, **metadata)View on GitHub#
- remove_labels(typename)View on GitHub#
- Return type:
None