langtest.transform.robustness.AddContext#
- class AddContext#
Bases:
BaseRobustness
- __init__()#
Methods
__init__
()async_run
(sample_list, model, **kwargs)Creates a task to run the robustness measure.
run
(sample_list, model, **kwargs)Abstract method that implements the robustness measure.
transform
(sample_list[, starting_context, ...])Converts input sentences using a conversion dictionary :param sample_list: List of sentences to process.
Attributes
alias_name
- async classmethod async_run(sample_list: List[Sample], model: ModelFactory, **kwargs)#
Creates a task to run the robustness measure.
- Parameters:
sample_list (List[Sample]) – The input data to be transformed.
model (ModelFactory) – The model to be used for evaluation.
**kwargs – Additional arguments to be passed to the robustness measure.
- Returns:
The task that runs the robustness measure.
- Return type:
asyncio.Task
- abstract async static run(sample_list: List[Sample], model: ModelFactory, **kwargs) List[Sample] #
Abstract method that implements the robustness measure.
- Parameters:
sample_list (List[Sample]) – The input data to be transformed.
model (ModelFactory) – The model to be used for evaluation.
**kwargs – Additional arguments to be passed to the robustness measure.
- Returns:
The transformed data based on the implemented robustness measure.
- Return type:
List[Sample]
- static transform(sample_list: List[Sample], starting_context: List[str] | None = None, ending_context: List[str] | None = None, strategy: str | None = None) List[Sample] #
Converts input sentences using a conversion dictionary :param sample_list: List of sentences to process. :param strategy: Config method to adjust where will context tokens added. start, end or combined. :param starting_context: list of terms (context) to input at start of sentences. :param ending_context: list of terms (context) to input at end of sentences.
- Returns:
List of sentences that context added at to begging, end or both, randomly.