pyrit.prompt_converter.KeywordSelectionStrategy#
- class KeywordSelectionStrategy(*, keyword: str, context_before: int = 0, context_after: int = 0, case_sensitive: bool = True)[source]#
Bases:
TextSelectionStrategySelects text around a keyword with optional context.
- __init__(*, keyword: str, context_before: int = 0, context_after: int = 0, case_sensitive: bool = True) None[source]#
Initializes the keyword selection strategy.
- Parameters:
keyword (str) – The keyword to search for.
context_before (int) – Number of characters to include before the keyword. Defaults to 0.
context_after (int) – Number of characters to include after the keyword. Defaults to 0.
case_sensitive (bool) – Whether the keyword search is case-sensitive. Defaults to True.
Methods
__init__(*, keyword[, context_before, ...])Initializes the keyword selection strategy.
select_range(*, text)Selects the range around the first occurrence of the keyword.