pyrit.prompt_converter.WordIndexSelectionStrategy#

class WordIndexSelectionStrategy(*, indices: List[int])[source]#

Bases: WordSelectionStrategy

Selects words based on their indices in the word list.

__init__(*, indices: List[int]) None[source]#

Initializes the word index selection strategy.

Parameters:

indices (List[int]) – The list of word indices to select.

Methods

__init__(*, indices)

Initializes the word index selection strategy.

select_range(*, text[, word_separator])

Selects a character range by first selecting words, then converting to character positions.

select_words(*, words)

Selects words at the specified indices.

select_words(*, words: List[str]) List[int][source]#

Selects words at the specified indices.

Parameters:

words (List[str]) – The list of words to select from.

Returns:

The list of valid indices.

Return type:

List[int]

Raises:

ValueError – If any indices are out of range.