gec_metrics.metrics.some module

class gec_metrics.metrics.some.SOME(config: Config = None)[source]

Bases: MetricBaseForReferenceFree

class Config(model_g: str = 'gfm-models/grammer', model_f: str = 'gfm-models/fluency', model_m: str = 'gfm-models/meaning', weight_g: float = 0.55, weight_f: float = 0.43, weight_m: float = 0.02, no_cuda: bool = False, batch_size: int = 32, max_length: int = 128)[source]

Bases: Config

SOME configuration. - model_g (str): Model for grammaticality. - model_f (str): Model for fluency. - model_m (str): Model for meaning preservation. - weight_g (float): Weight for the grammaticality score. - weight_f (float): Weight for the fluency score. - weight_m (float): Weight for the meaning preservation score. - no_cuda (bool): If True, work on CPU. - batch_size (int): Batch size for inference. - max_length (int): Maximum length of inputs.

batch_size: int = 32
max_length: int = 128
model_f: str = 'gfm-models/fluency'
model_g: str = 'gfm-models/grammer'
model_m: str = 'gfm-models/meaning'
no_cuda: bool = False
weight_f: float = 0.43
weight_g: float = 0.55
weight_m: float = 0.02
min_max_normalize(x: int, x_min: int = 1, x_max: int = 4)[source]

Normalizes the input values in the range x_min to x_max. - x (int): Input value. - x_min (int): Lower bound of the range. - x_max (int): Upper bound of the range.

score_sentence(sources: list[str], hypotheses: list[str]) list[float][source]

Calculate sentence-level scores.

Parameters:
  • sources (list[str]) – Source sentence. The shape is (num_sentences, )

  • hypotheses (list[str]) – Corrected sentences. The shape is (num_sentences, )

Returns:

The sentence-level scores.

Return type:

list[float]