neuralset.events.transforms.text.AddContextToWords

class neuralset.events.transforms.text.AddContextToWords(*, infra: Backend | None = None, sentence_only: bool = True, max_context_len: int | None = None, split_field: str = 'split')[source][source]

Add a context field to the events dataframe, for each word event, by concatenating the sentence fields.

Warning

Unstable API — the context representation (per-word concatenated strings) will be replaced with compact indices in a future release.

Parameters:
  • sentence_only (bool) – only use current sentence as context

  • max_context_len (None or int) – if not None, caps the context len to a given number of words (counted through whitespaces)

  • split_field (str) – field on which to reset contexts. If empty, context is only reset for new timelines.