langtest.transform.robustness.StripPunctuation#

class StripPunctuation#

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[, whitelist])

Add punctuation from the string, if there isn't punctuation at the end skip it

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], whitelist: List[str] | None = None) List[Sample]#

Add punctuation from the string, if there isn’t punctuation at the end skip it

Parameters:
  • sample_list – List of sentences to apply robustness.

  • whitelist – Whitelist for punctuations to strip from sentences.

Returns:

List of sentences that punctuation is stripped.