pyrit.prompt_converter.WordSelectionStrategy#
- class WordSelectionStrategy[source]#
Bases:
TextSelectionStrategyBase class for word-level selection strategies.
Word selection strategies work by splitting text into words and selecting specific word indices. They provide a select_words() method and implement select_range() by converting word selections to character ranges.
- __init__()#
Methods
__init__()select_range(*, text[, word_separator])Selects a character range by first selecting words, then converting to character positions.
select_words(*, words)Selects word indices to be converted.
- select_range(*, text: str, word_separator: str = ' ') tuple[int, int][source]#
Selects a character range by first selecting words, then converting to character positions.
This implementation splits the text by word_separator, gets selected word indices, then calculates the character range that spans those words.