modifiers.slicer#
Module Contents#
Classes#
Slices a document based on indices or strings. |
API#
- class modifiers.slicer.Slicer(
- left: int | str | None = 0,
- right: int | str | None = None,
- include_left: bool = True,
- include_right: bool = True,
- strip: bool = True,
Bases:
nemo_curator.modifiers.DocumentModifierSlices a document based on indices or strings.
Initialization
Args: left (Union[int, str], optional): If the provided value is an int, slice the string from this index (inclusive). If the provided value is a str, slice the string from the first occurence of this substring. right (Union[int, str], optional): If the provided value is an int, slice the string to this index (exclusive). If the provided value is a str, slice the string to the last occurence of this substring. If None, right is set to the length of the string. include_left (bool): Only used if
leftis a string. If True, the value ofleftis included in the slicing result. Defaults to False. include_right (bool): Only used ifrightis a string. If True, the value ofrightis included in the slicing result. Defaults to False. strip (bool): If True, strip the resulting string.- modify_document(text: str) str#