langtest.transform.robustness.SwapEntities#
- class SwapEntities#
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[, labels, terminology])Swaps named entities with the new one from the terminology extracted from passed data.
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], labels: List[List[str]] | None = None, terminology: Dict[str, List[str]] | None = None) List[Sample] #
Swaps named entities with the new one from the terminology extracted from passed data.
- Parameters:
sample_list – List of sentences to process.
labels – Corresponding labels to make changes according to sentences.
terminology – Dictionary of entities and corresponding list of words.
- Returns:
List of sentences that entities swapped with the terminology.