pyrit.prompt_converter.WordKeywordSelectionStrategy#

class WordKeywordSelectionStrategy(*, keywords: List[str], case_sensitive: bool = True)[source]#

Bases: WordSelectionStrategy

Selects words that match specific keywords.

__init__(*, keywords: List[str], case_sensitive: bool = True) None[source]#

Initialize the word keyword selection strategy.

Parameters:
  • keywords (List[str]) – The list of keywords to match.

  • case_sensitive (bool) – Whether matching is case-sensitive. Defaults to True.

Methods

__init__(*, keywords[, case_sensitive])

Initialize the word keyword selection strategy.

select_range(*, text[, word_separator])

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

select_words(*, words)

Select words that match the keywords.

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

Select words that match the keywords.

Parameters:

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

Returns:

The list of indices where keywords were found.

Return type:

List[int]