Skip to content

span_field

allennlp.data.fields.span_field

[SOURCE]


SpanField#

class SpanField(Field[torch.Tensor]):
 | def __init__(
 |     self,
 |     span_start: int,
 |     span_end: int,
 |     sequence_field: SequenceField
 | ) -> None

A SpanField is a pair of inclusive, zero-indexed (start, end) indices into a SequenceField, used to represent a span of text. Because it's a pair of indices into a SequenceField, we take one of those as input to make the span's dependence explicit and to validate that the span is well defined.

Parameters

  • span_start : int
    The index of the start of the span in the SequenceField.
  • span_end : int
    The inclusive index of the end of the span in the SequenceField.
  • sequence_field : SequenceField
    A field containing the sequence that this SpanField is a span inside.

get_padding_lengths#

class SpanField(Field[torch.Tensor]):
 | ...
 | @overrides
 | def get_padding_lengths(self) -> Dict[str, int]

as_tensor#

class SpanField(Field[torch.Tensor]):
 | ...
 | @overrides
 | def as_tensor(self, padding_lengths: Dict[str, int]) -> torch.Tensor

empty_field#

class SpanField(Field[torch.Tensor]):
 | ...
 | @overrides
 | def empty_field(self)