gec_metrics.analysis.attributor.shapley module
- class gec_metrics.analysis.attributor.shapley.AttributorShapley(config)[source]
Bases:
AttributorBase- generate(src: str, edits: list[Edit] | list[list[Edit]]) list[dict][source]
Generate edited sentence by applying all 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]
Caluclate Shapley 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]