gec_metrics.analysis.attributor.shapley_sampling module

class gec_metrics.analysis.attributor.shapley_sampling.AttributorShapleySampling(config)[source]

Bases: AttributorBase

generate(src: str, edits: list[Edit]) list[dict][source]

Generate edited sentence by applying sampled patterns of edits.

Parameters:
  • src (str) – source sentence.

  • edits (list[errant.edit.Edit]) – Edit to be applied to the source.

Returns:

Each element has two keys:

”sentence”: An edited sentence. “indices”: Indices of edits that were applied to the source sentence.

Return type:

list[Dict]

post_process(scores: list[float], sent_level_score: float | None = None, indices: list[tuple] | None = None) list[float][source]

Calculate Shapley sampling values.

Parameters:
  • scores (list[float]) – delta M() scores.

  • sent_level_score (Optional[float]) – Used when normalization.

  • indices (Optional[list[Tuple]]) – Which edits were applied to the source.

Returns:

Post pocessed scores.

Return type:

list[float]