pyrit.prompt_converter.TextSelectionStrategy#

class TextSelectionStrategy[source]#

Bases: ABC

Base class for text selection strategies used by SelectiveTextConverter and WordLevelConverter. Defines how to select a region of text or words for conversion.

__init__()#

Methods

__init__()

select_range(*, text)

Selects a range of characters in the text to be converted.

abstract select_range(*, text: str) tuple[int, int][source]#

Selects a range of characters in the text to be converted.

Parameters:

text (str) – The input text to select from.

Returns:

A tuple of (start_index, end_index) representing the character range.

The range is inclusive of start_index and exclusive of end_index.

Return type:

tuple[int, int]